.app-nav {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.nav-inner {
  width: calc(100% - 76px);
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-brand {
  color: var(--ink);
  font-size: 16px;
  font-weight: 750;
  text-decoration: none;
}

.nav-links { display: flex; align-self: stretch; gap: 4px; }
.nav-links a {
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
}
.nav-links a:hover, .nav-links a.active { border-color: var(--accent); color: var(--accent); }

.nav-account { margin-left: auto; display: flex; align-items: center; gap: 13px; font-size: 13px; }
.nav-account form { margin: 0; }
.nav-logout { padding: 5px 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.nav-logout:hover { color: var(--danger); }

.message-stack { padding-top: 14px; }
.flash { padding: 11px 13px; border-left: 3px solid #527287; background: #edf5f8; color: #27485b; font-size: 13px; }
.flash + .flash { margin-top: 7px; }
.flash.success { border-color: var(--success); background: #edf8f1; color: #175b35; }
.flash.warning { border-color: #d0962c; background: #fff7e8; color: #714b06; }
.flash.error { border-color: var(--danger); background: var(--danger-soft); color: #7a271a; }

.login-body { min-height: 100vh; background: #eef1f3; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 0.9fr) minmax(420px, 1.1fr); }
.login-intro {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100vh;
  padding: clamp(48px, 7vw, 110px);
  background: #17191c;
  color: #fff;
}
.login-kicker { margin: 0 0 12px; color: #67c5b8; font-size: 11px; font-weight: 800; }
.login-intro h1 { margin: 0; font-size: clamp(34px, 5vw, 62px); line-height: 1.1; }
.login-intro > p:last-child { margin: 18px 0 0; color: #aeb6bd; font-size: 15px; }
.login-panel {
  width: min(430px, calc(100% - 48px));
  align-self: center;
  justify-self: center;
  padding: 42px 0;
}
.login-heading { margin-bottom: 28px; }
.login-heading p { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; }
.login-heading h2 { margin: 0; font-size: 30px; }
.auth-form { margin-top: 20px; }

.form-field { margin-bottom: 20px; }
.form-field label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.form-field label span { margin-left: 3px; color: var(--danger); }
.form-field input:not([type="checkbox"]), .form-field select {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid #aeb6bd;
  border-radius: 4px;
  background: #fff;
  outline: none;
}
.form-field input:focus, .form-field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0, 107, 99, .1); }
.form-field input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); }
.form-field small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.field-error { display: block; margin-top: 6px; color: var(--danger); font-size: 12px; }
.form-alert { margin-bottom: 18px; padding: 11px 13px; border-left: 3px solid var(--danger); background: var(--danger-soft); color: #7a271a; font-size: 13px; }

.primary-action, .secondary-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.primary-action:hover { background: var(--accent-dark); }
.secondary-action { border-color: #b7bec4; background: #fff; color: var(--ink); }
.secondary-action:hover { border-color: #747e87; }
.full-width { width: 100%; }
.text-link { color: var(--accent); font-size: 13px; font-weight: 650; text-decoration: none; }

.admin-main { padding: 42px 0 70px; }
.narrow-main { max-width: 760px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.page-heading h1 { margin: 0; font-size: 32px; }
.page-subtitle { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 42px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.admin-metrics article { min-width: 0; padding: 22px 20px; border-right: 1px solid var(--line); }
.admin-metrics article:first-child { padding-left: 0; }
.admin-metrics article:last-child { border-right: 0; }
.admin-metrics span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.admin-metrics strong { font-size: 30px; }

.admin-section { margin-top: 28px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 2px solid var(--ink); }
.section-heading h2 { margin: 0; font-size: 18px; }
.section-heading a { color: var(--accent); font-size: 13px; text-decoration: none; }
.admin-table-wrap { width: 100%; overflow-x: auto; }
.admin-table { min-width: 680px; }
.admin-table th { height: 44px; background: var(--soft); }
.admin-table td { height: 55px; }
.admin-table td small { display: block; margin-top: 3px; color: var(--accent); font-size: 10px; }

.state-badge { display: inline-block; min-width: 45px; padding: 4px 6px; border: 1px solid; text-align: center; font-size: 11px; font-weight: 700; }
.state-badge.enabled { border-color: #86b99b; color: var(--success); }
.state-badge.disabled { border-color: #c5cbd0; color: #707981; }

.management-tools {
  display: flex;
  justify-content: space-between;
  gap: 28px;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--soft);
}
.filter-form { display: flex; align-items: center; gap: 8px; }
.filter-form input, .filter-form select {
  height: 42px;
  padding: 0 11px;
  border: 1px solid #b7bec4;
  border-radius: 4px;
  background: #fff;
}
.filter-form input { width: 230px; }
.bulk-import { display: flex; align-items: center; gap: 10px; }
.bulk-import form { display: flex; align-items: center; gap: 8px; }
.bulk-import label { font-size: 12px; font-weight: 700; }
.bulk-import input[type="file"] { width: 205px; font-size: 11px; }
.bulk-import > a { color: var(--accent); font-size: 12px; white-space: nowrap; }
.import-result { margin-top: 16px; padding: 15px; border-left: 3px solid var(--warning); background: #fff8eb; font-size: 13px; }
.import-result details { margin-top: 8px; }
.import-result ul { max-height: 190px; overflow: auto; margin: 8px 0 0; padding-left: 22px; }
.import-result li { margin: 5px 0; }
.user-table-section { margin-top: 20px; }
.user-table { min-width: 980px; }
.remark-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.actions-heading { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.row-actions a, .row-actions button { border: 0; background: none; color: var(--accent); font-size: 12px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.row-actions form { margin: 0; }
.row-actions .danger-action { color: var(--danger); }

.form-surface { border-top: 2px solid var(--ink); padding-top: 24px; }
.admin-form { max-width: 560px; }
.form-actions { display: flex; gap: 10px; margin-top: 28px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .login-layout { grid-template-columns: 1fr; }
  .login-intro { min-height: 210px; justify-content: center; padding: 36px 24px; }
  .login-intro h1 { font-size: 34px; }
  .login-panel { min-height: calc(100vh - 210px); align-content: center; }
  .admin-metrics { grid-template-columns: repeat(2, 1fr); }
  .admin-metrics article:nth-child(2) { border-right: 0; }
  .admin-metrics article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .admin-metrics article:nth-child(3) { padding-left: 0; }
  .management-tools { align-items: stretch; flex-direction: column; }
  .bulk-import { justify-content: space-between; }
}

@media (max-width: 650px) {
  .nav-inner { gap: 14px; }
  .nav-brand { display: none; }
  .nav-links { gap: 0; }
  .nav-links a { padding: 0 8px; font-size: 12px; }
  .nav-account { gap: 8px; font-size: 11px; }
  .admin-main { padding-top: 30px; }
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 27px; }
  .admin-metrics article { padding: 17px 12px; }
  .admin-metrics strong { font-size: 25px; }
  .filter-form { align-items: stretch; flex-direction: column; }
  .filter-form input { width: 100%; }
  .bulk-import, .bulk-import form { align-items: stretch; flex-direction: column; }
  .bulk-import input[type="file"] { width: 100%; }
  .login-panel { width: min(100% - 32px, 430px); }
  .user-table { min-width: 0; table-layout: fixed; }
  .user-table th:nth-child(3), .user-table td:nth-child(3),
  .user-table th:nth-child(5), .user-table td:nth-child(5) { display: none; }
  .user-table th:nth-child(1) { width: 22%; }
  .user-table th:nth-child(2) { width: 18%; }
  .user-table th:nth-child(4) { width: 16%; }
  .user-table th:nth-child(6) { width: 44%; }
  .user-table th, .user-table td { padding-left: 6px; padding-right: 6px; white-space: normal; }
  .row-actions { flex-wrap: wrap; gap: 5px 7px; }
}
