/*  Review CMS - interface styles.
 *
 *  One stylesheet, no framework and no build step, so the office PC can serve
 *  it straight off disk. Colours are CSS variables in one place at the top;
 *  the dark theme redefines those variables and nothing else, which is why
 *  every component below is written against the tokens rather than a hex code.
 */

:root {
  --brand: #0E5D74;
  --brand-dark: #083D4D;
  --accent: #0EA5D6;
  --accent-soft: #E6F6F4;

  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFB;
  --surface-3: #EEF2F5;
  --line: #E1E8ED;
  --line-strong: #CFDAE1;

  --text: #16242C;
  --text-2: #4C616D;
  --text-3: #7D909B;

  --green: #16A34A;
  --green-bg: #E8F7EE;
  --amber: #D97706;
  --amber-bg: #FEF3E2;
  --orange: #EA580C;
  --orange-bg: #FFEFE6;
  --red: #DC2626;
  --red-bg: #FDECEC;
  --blue: #2563EB;
  --blue-bg: #E8F0FE;
  --grey: #64748B;
  --grey-bg: #EEF1F4;

  --shadow-sm: 0 1px 2px rgba(16, 36, 44, .06);
  --shadow: 0 2px 8px rgba(16, 36, 44, .08);
  --shadow-lg: 0 12px 34px rgba(16, 36, 44, .16);

  --radius: 10px;
  --radius-sm: 7px;
  --sidebar-w: 236px;
  --header-h: 60px;

  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
}

html[data-theme="dark"] {
  --brand: #12ACD8;
  --brand-dark: #0B2E3A;
  --accent: #26BCE4;
  --accent-soft: #14323D;

  --bg: #0C1519;
  --surface: #131F25;
  --surface-2: #172831;
  --surface-3: #1D323C;
  --line: #233945;
  --line-strong: #2E4854;

  --text: #E7EFF3;
  --text-2: #A6BAC4;
  --text-3: #7A929E;

  --green-bg: #10281B;
  --amber-bg: #2A2011;
  --orange-bg: #2B1B11;
  --red-bg: #2C1516;
  --blue-bg: #14203A;
  --grey-bg: #1B2830;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 2px 10px rgba(0, 0, 0, .45);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

/* ------------------------------------------------------------- sign-in -- */

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--surface);
}

.login-art {
  background: linear-gradient(155deg, var(--brand-dark), var(--brand) 55%, var(--accent));
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.login-art h1 { font-size: 32px; line-height: 1.2; max-width: 12ch; }
.login-art p { max-width: 42ch; color: #D6EEF6; font-size: 15px; margin: 0; }
.login-art .points { display: grid; gap: 10px; margin-top: 8px; }
.login-art .point { display: flex; gap: 10px; align-items: flex-start; color: #EAF7FB; font-size: 14px; }
.login-art .point span:first-child { opacity: .85; }

.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-form { width: 100%; max-width: 340px; }
.login-form h2 { font-size: 22px; margin-bottom: 4px; }
.login-form .sub { color: var(--text-2); margin-bottom: 24px; font-size: 13px; }

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-art { padding: 34px 26px; }
  .login-art h1 { font-size: 25px; }
  .login-art .points { display: none; }
}

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

.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: var(--brand-dark);
  color: #CFE4EC;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
  min-height: var(--header-h);
}

.sidebar .brand .mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(140deg, var(--accent), #7FD3EA);
  display: grid; place-items: center; color: #06303C; font-weight: 800; font-size: 15px;
}
.sidebar .brand b { color: #fff; font-size: 14px; display: block; line-height: 1.25; }
.sidebar .brand small { color: #8FBFD1; font-size: 11px; }

.nav { padding: 10px 10px 20px; display: flex; flex-direction: column; gap: 2px; }
.nav .group { margin: 14px 0 4px; padding: 0 10px; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: #6E9DAF; }

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border-radius: var(--radius-sm);
  color: #CFE4EC; font-size: 13.5px; font-weight: 500;
  text-decoration: none; transition: background .12s, color .12s;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.active { background: var(--accent); color: #04252F; font-weight: 650; }
.nav a .ic { width: 17px; text-align: center; flex: none; font-size: 14px; }
.nav a .count {
  margin-left: auto; background: rgba(255, 255, 255, .16); color: #fff;
  border-radius: 20px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.nav a.active .count { background: rgba(0, 0, 0, .18); color: #04252F; }
.nav a .count.alert { background: var(--red); color: #fff; }

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

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; position: sticky; top: 0; z-index: 30;
}

.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { width: 100%; padding-left: 34px; }
.topbar .search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }

.topbar .spacer { flex: 1; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  display: grid; place-items: center; font-size: 15px; position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 5px; right: 5px; min-width: 15px; height: 15px; padding: 0 3px;
  border-radius: 8px; background: var(--red); color: #fff; font-size: 9.5px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}

.user-chip {
  display: flex; align-items: center; gap: 9px; padding: 5px 9px 5px 5px;
  border-radius: 20px; border: 1px solid var(--line); cursor: pointer; background: var(--surface);
}
.user-chip:hover { background: var(--surface-2); }
.user-chip .avatar {
  width: 25px; height: 25px; border-radius: 50%; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 700;
}
.user-chip b { font-size: 12.5px; }
.user-chip small { display: block; color: var(--text-3); font-size: 10.5px; line-height: 1; }

.content { padding: 22px 24px 60px; flex: 1; min-width: 0; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head .sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .content { padding: 16px 14px 60px; }
  .menu-toggle { display: grid !important; }
}
.menu-toggle { display: none; }

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

input, select, textarea, .input {
  width: 100%; padding: 8px 11px; font: inherit; font-size: 13.5px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-3); color: var(--text-3); }
textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
select { cursor: pointer; }

label.field { display: block; margin-bottom: 12px; }
label.field > span.lbl {
  display: block; font-size: 11.5px; font-weight: 600; color: var(--text-2);
  margin-bottom: 4px; letter-spacing: .01em;
}
label.field .hint { font-size: 11px; color: var(--text-3); margin-top: 3px; display: block; }
label.field.req > span.lbl::after { content: " *"; color: var(--red); }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: auto; margin: 0; accent-color: var(--brand); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 14px; }
@media (max-width: 780px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; font: inherit; font-size: 13px; font-weight: 600;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, transform .06s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #04252F; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger:hover { filter: brightness(.93); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.sm { padding: 5px 9px; font-size: 12px; border-radius: 6px; }
.btn.wa { background: #25D366; border-color: #25D366; color: #06331A; }
.btn.block { width: 100%; }

.btn-group { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.btn-group button {
  border: 0; background: var(--surface); padding: 6px 12px; font: inherit; font-size: 12.5px;
  color: var(--text-2); cursor: pointer; border-right: 1px solid var(--line);
}
.btn-group button:last-child { border-right: 0; }
.btn-group button.on { background: var(--brand); color: #fff; font-weight: 600; }

/* --------------------------------------------------------------- cards -- */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card > .card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card > .card-head h2 { font-size: 14px; }
.card > .card-head .sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.card > .card-body { padding: 16px; }
.card > .card-body.tight { padding: 0; }

.stat-grid {
  display: grid; gap: 12px; margin-bottom: 16px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 650; }
.stat .v { font-size: 25px; font-weight: 700; line-height: 1.15; margin-top: 5px; letter-spacing: -.02em; }
.stat .d { font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
.stat.accent-bar::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent);
}
.stat.good .v { color: var(--green); }
.stat.warn .v { color: var(--amber); }
.stat.bad .v { color: var(--red); }

.chart-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }

/* -------------------------------------------------------------- tables -- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 9px 12px; background: var(--surface-2);
  border-bottom: 1px solid var(--line); color: var(--text-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: .045em; font-weight: 700;
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .muted { color: var(--text-3); }
table.data .strong { font-weight: 650; }
table.data .nowrap { white-space: nowrap; }

.empty-state { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty-state .big { font-size: 30px; margin-bottom: 8px; opacity: .55; }
.empty-state b { display: block; color: var(--text-2); margin-bottom: 4px; font-size: 14px; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border-top: 1px solid var(--line); flex-wrap: wrap;
}
.pager .info { color: var(--text-3); font-size: 12.5px; }
.pager .pages { display: flex; gap: 5px; align-items: center; }

/* -------------------------------------------------------------- badges -- */

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2.5px 9px;
  border-radius: 20px; font-size: 11.5px; font-weight: 650; white-space: nowrap;
  background: var(--grey-bg); color: var(--grey);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.blue { background: var(--blue-bg); color: var(--blue); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.orange { background: var(--orange-bg); color: var(--orange); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.grey { background: var(--grey-bg); color: var(--grey); }
.badge.outline { background: transparent; border: 1px solid var(--line-strong); color: var(--text-2); }

.pill { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--surface-3); color: var(--text-2); font-weight: 600; }

/* ------------------------------------------------------------- filters -- */

.filters {
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  padding: 13px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.filters label.field { margin: 0; }
.filters .actions { display: flex; align-items: flex-end; gap: 8px; }

/* -------------------------------------------------------------- modals -- */

.overlay {
  position: fixed; inset: 0; background: rgba(9, 22, 28, .55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 100; overflow-y: auto;
  animation: fade .14s ease-out;
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.modal {
  background: var(--surface); border-radius: 13px; width: 100%; max-width: 620px;
  box-shadow: var(--shadow-lg); animation: rise .16s ease-out; overflow: hidden;
}
.modal.wide { max-width: 940px; }
.modal.narrow { max-width: 440px; }
.modal .modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal .modal-head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.modal .modal-body { padding: 18px 20px; max-height: calc(100vh - 210px); overflow-y: auto; }
.modal .modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--line); background: var(--surface-2);
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}
.modal .modal-foot .left { margin-right: auto; }

.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
  font-weight: 700; margin: 20px 0 10px; padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.section-title:first-child { margin-top: 0; }

/* -------------------------------------------------------------- toasts -- */

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  padding: 11px 14px; min-width: 260px; max-width: 400px; animation: rise .16s ease-out;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
.toast b { display: block; font-size: 13px; margin-bottom: 1px; }
.toast span { font-size: 12.5px; color: var(--text-2); }

/* ------------------------------------------------------------ timeline -- */

.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 5px; bottom: 5px; width: 2px; background: var(--line); }
.timeline .item { position: relative; padding: 0 0 15px; }
.timeline .item::before {
  content: ""; position: absolute; left: -20px; top: 5px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--surface);
}
.timeline .item.green::before { background: var(--green); }
.timeline .item.red::before { background: var(--red); }
.timeline .item.grey::before { background: var(--line-strong); }
.timeline .when { font-size: 11.5px; color: var(--text-3); }
.timeline .what { font-size: 13.5px; font-weight: 600; }
.timeline .detail { font-size: 12.5px; color: var(--text-2); }

/* ------------------------------------------------------- misc utilities -- */

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.tight { gap: 5px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.mb0 { margin-bottom: 0; } .mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; } .mt16 { margin-top: 16px; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.hidden { display: none !important; }
.spread { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.col { flex: 1 1 260px; min-width: 0; }

.note {
  padding: 11px 13px; border-radius: var(--radius-sm); font-size: 12.5px;
  background: var(--accent-soft); color: var(--text); border: 1px solid var(--line);
}
.note.warn { background: var(--amber-bg); color: var(--amber); border-color: transparent; }
.note.err { background: var(--red-bg); color: var(--red); border-color: transparent; }
.note.ok { background: var(--green-bg); color: var(--green); border-color: transparent; }

.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 6px 14px; font-size: 13px; }
.kv .k { color: var(--text-3); font-size: 12px; }
.kv .v { font-weight: 550; word-break: break-word; }

.preview-box {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 15px; white-space: pre-wrap; font-size: 13px; line-height: 1.6; max-height: 320px; overflow-y: auto;
}

.spinner {
  width: 15px; height: 15px; border: 2px solid var(--line-strong); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading { padding: 46px; text-align: center; color: var(--text-3); }

.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; }

.dup-card {
  border: 1px solid var(--amber); background: var(--amber-bg); border-radius: var(--radius-sm);
  padding: 11px 13px; margin-bottom: 9px;
}
.dup-card b { color: var(--text); }

.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; padding: 9px 14px; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

.stars { color: #F0A500; letter-spacing: 1px; }

.notif-item { padding: 11px 15px; border-bottom: 1px solid var(--line); display: flex; gap: 10px; cursor: pointer; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.notif-item .ic { font-size: 15px; }
.notif-item .when { font-size: 11px; color: var(--text-3); }

@media print {
  .sidebar, .topbar, .page-head .actions, .filters, .pager { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { border: 0; box-shadow: none; }
}
