:root {
  --nav-bg: #16324f;
  --nav-bg-hover: #1f4a72;
  --nav-bg-active: #0f2540;
  --nav-text: #c7dbec;
  --nav-text-dim: #7fa3c2;
  --accent: #1a7fc1;
  --accent-dark: #0f4b7a;
  --page-bg: #eef1f5;
  --card: #ffffff;
  --border: #d3dce5;
  --text: #1c2b36;
  --text-dim: #5c7a8f;
  --ok: #1f8a4c;
  --warn: #b06f00;
  --danger: #c0392b;
  --radius: 6px;
  --nav-width: 248px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--page-bg);
}

a { color: var(--accent-dark); }

/* ---------------------------------------------------------- app shell --- */

.app { display: flex; min-height: 100%; }

.nav {
  width: var(--nav-width);
  flex: 0 0 var(--nav-width);
  background: var(--nav-bg);
  color: var(--nav-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.nav-brand .mark {
  width: 24px; height: 24px; border-radius: 5px;
  background: linear-gradient(135deg, #2aa8e0, #1a7fc1);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}

.nav-filter { padding: 10px; }
.nav-filter input {
  width: 100%;
  padding: 7px 9px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.22);
  color: #fff;
  font-size: 13px;
}
.nav-filter input::placeholder { color: var(--nav-text-dim); }
.nav-filter input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.nav-scroll { overflow-y: auto; flex: 1; padding-bottom: 12px; }

.nav-section > .nav-section-title {
  display: flex; align-items: center; gap: 7px;
  width: 100%;
  padding: 9px 14px;
  background: none; border: 0;
  color: var(--nav-text-dim);
  font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase;
  cursor: pointer; text-align: left;
}
.nav-section > .nav-section-title:hover { color: #fff; }
.nav-section .caret { transition: transform 0.15s; font-size: 9px; }
.nav-section.collapsed .caret { transform: rotate(-90deg); }
.nav-section.collapsed .nav-items { display: none; }

.nav-items { list-style: none; margin: 0; padding: 0; }
.nav-items a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 14px 8px 26px;
  color: var(--nav-text); text-decoration: none; font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav-items a:hover { background: var(--nav-bg-hover); color: #fff; }
.nav-items a.active {
  background: var(--nav-bg-active); color: #fff;
  border-left-color: var(--accent); font-weight: 600;
}

.badge {
  background: var(--accent); color: #fff;
  border-radius: 10px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.badge.zero { display: none; }

.nav-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 11px 14px; font-size: 12px; color: var(--nav-text-dim);
}

/* ------------------------------------------------------------- content --- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 20px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }
.topbar .who { color: var(--text-dim); font-size: 13px; display: flex; align-items: center; gap: 12px; }

.content { padding: 20px; flex: 1; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 18px;
}
.card > h2 {
  margin: 0; padding: 13px 16px; font-size: 14px; font-weight: 600;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-body { padding: 16px; }
.card-body > p:first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }

.muted { color: var(--text-dim); }
.small { font-size: 12.5px; }

/* --------------------------------------------------------------- forms --- */

.field { margin-bottom: 13px; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.field .hint { color: var(--text-dim); font-size: 12px; margin-top: 3px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 4px;
  font: inherit; color: var(--text); background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { min-height: 78px; resize: vertical; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 220px; }

button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 8px 15px; border-radius: 4px;
  border: 1px solid var(--accent-dark); background: var(--accent-dark); color: #fff;
}
button:hover, .btn:hover { background: #0c3d63; }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary, .btn.secondary {
  background: #fff; color: var(--accent-dark); border-color: var(--border);
}
button.secondary:hover { background: #f3f6f9; }
button.danger { background: var(--danger); border-color: var(--danger); }
button.danger:hover { background: #a5301f; }
button.small { padding: 5px 10px; font-size: 12.5px; }

/* --------------------------------------------------------------- table --- */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); }
th {
  background: #f5f7fa; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-dim); font-weight: 700;
}
tbody tr:hover { background: #f7fafc; }
td .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 11px;
  font-size: 11.5px; font-weight: 700;
}
.pill.active { background: #e3f5e9; color: var(--ok); }
.pill.pending { background: #fdf1dc; color: var(--warn); }
.pill.disabled { background: #eceff2; color: var(--text-dim); }
.pill.admin { background: #e5eff8; color: var(--accent-dark); }
.pill.consultant { background: #eaf3ec; color: #2e6f4a; }
.pill.client { background: #f2ecf7; color: #6a4a8f; }

/* -------------------------------------------------------------- notices --- */

.notice { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 15px; font-size: 13.5px; }
.notice.error { background: #fdecea; border: 1px solid #f5c6c2; color: #922; }
.notice.ok { background: #e8f6ed; border: 1px solid #bfe3cc; color: #1c6b3f; }
.notice.info { background: #e9f2fa; border: 1px solid #c3dcf0; color: #17527d; }
.notice.warn { background: #fdf4e3; border: 1px solid #f0dcb0; color: #8a5a00; }

.linkbox {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; word-break: break-all;
  background: #f5f7fa; border: 1px solid var(--border); border-radius: 4px;
  padding: 9px 11px; margin: 9px 0;
}

.empty { padding: 34px 16px; text-align: center; color: var(--text-dim); }

/* ---------------------------------------------------------- auth pages --- */

.auth-page {
  min-height: 100vh; display: grid; place-items: center; padding: 22px;
  background: linear-gradient(160deg, #16324f, #0d1f33);
}
.auth-card {
  background: #fff; border-radius: 9px; padding: 30px;
  width: 100%; max-width: 400px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
}
.auth-card h1 { margin: 0 0 5px; font-size: 20px; }
.auth-card .sub { color: var(--text-dim); margin: 0 0 20px; font-size: 13.5px; }
.auth-card button[type=submit] { width: 100%; padding: 10px; margin-top: 5px; }
.auth-alt { margin-top: 15px; text-align: center; font-size: 13px; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 30, 45, 0.55);
  display: grid; place-items: center; padding: 20px; z-index: 20;
}
.modal {
  background: #fff; border-radius: 8px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
}
.modal h2 {
  margin: 0; padding: 15px 18px; font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.modal-body { padding: 18px; }
.modal-foot {
  padding: 13px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 9px;
}

@media (max-width: 820px) {
  .app { flex-direction: column; }
  .nav { width: 100%; flex: none; height: auto; position: relative; }
  .nav-scroll { max-height: 55vh; }
}
