:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-muted: #eef4f5;
  --text: #172126;
  --muted: #63737a;
  --line: #d8e1e4;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --danger-bg: #fee4e2;
  --shadow: 0 14px 34px rgba(22, 37, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Meiryo, "Yu Gothic", "Yu Gothic UI", "Hiragino Kaku Gothic ProN",
    system-ui, sans-serif;
  font-size: 16px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px;
  background: #15282d;
  color: #f7fbfb;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #d6f4ef;
  color: var(--accent);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 3px;
  color: #b5c9cc;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav a,
.sidebar-foot a {
  border-radius: 8px;
  color: #d9e6e8;
  padding: 11px 12px;
}

.nav a:hover,
.sidebar-foot a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
  text-decoration: none;
}

.sidebar-foot {
  display: grid;
  gap: 8px;
  margin-top: auto;
  color: #b5c9cc;
  font-size: 14px;
}

.main {
  display: grid;
  align-content: start;
  gap: 20px;
  padding: 28px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.3;
}

h2 {
  font-size: 18px;
}

.page-head p,
.auth-card p,
.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.metrics article,
.panel,
.auth-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metrics article {
  padding: 16px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.panel,
.auth-card {
  overflow: hidden;
}

.auth-card {
  width: min(520px, 100%);
  margin: 6vh auto;
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f8fbfb;
  color: #435159;
  font-size: 13px;
}

td small,
td strong {
  display: block;
}

td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 5px 10px;
  background: var(--surface-muted);
  color: #334148;
  font-size: 13px;
  font-weight: 800;
}

.bar {
  width: 112px;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ecef;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.toolbar {
  display: flex;
  gap: 8px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.toolbar input {
  max-width: 340px;
}

.stack {
  display: grid;
  gap: 14px;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.wide {
  grid-column: 1 / -1;
}

.form-section-title {
  border-bottom: 1px solid var(--line);
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 800;
  padding: 10px 0 2px;
}

.plain-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.mini-panel {
  box-shadow: none;
  margin: 16px 0;
  padding: 14px;
}

.warning-text {
  color: #b45309;
  font-weight: 800;
}

.danger-text {
  color: var(--danger);
  font-weight: 800;
}

.check-row {
  align-content: center;
  grid-template-columns: auto 1fr;
  min-height: 42px;
}

.check-row input {
  width: auto;
}

label {
  display: grid;
  gap: 7px;
  color: #2d3a40;
  font-size: 14px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cdd8dc;
  border-radius: 8px;
  background: white;
  color: var(--text);
  outline: none;
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 120px;
  resize: vertical;
  padding: 10px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.button:hover {
  text-decoration: none;
}

.button.primary {
  background: var(--accent);
  color: white;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.secondary {
  border-color: var(--line);
  background: white;
  color: var(--text);
}

.button.danger {
  border-color: var(--danger-bg);
  background: var(--danger-bg);
  color: var(--danger);
}

.actions {
  display: flex;
  gap: 8px;
}

.delete-form {
  padding: 0 18px 18px;
}

.flash {
  border-radius: 8px;
  padding: 12px 14px;
  background: #dcfce7;
  color: #166534;
  font-weight: 700;
}

.flash.error {
  background: var(--danger-bg);
  color: var(--danger);
}

code {
  border-radius: 6px;
  background: #edf2f4;
  padding: 2px 6px;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metrics,
  .grid-form {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .main {
    padding: 18px;
  }

  .page-head,
  .toolbar {
    display: grid;
  }

  .nav,
  .metrics,
  .grid-form {
    grid-template-columns: 1fr;
  }
}
