/* CyberTips Case Manager - CPlus theme
   Charcoal sidebar, near-white workspace, white bordered panels, restrained pink accents. */
:root {
  --pink: #df2f72;
  --pink-soft: #fcebf2;
  --pink-text: #c74075;
  --ink: #20242c;
  --muted: #747983;
  --line: #e9eaee;
  --bg: #f7f8fa;
  --panel: #fff;
  --sidebar: #171b24;
  --sidebar-text: #abb1bf;
  --nav-active-bg: #332331;
  --nav-active-text: #ff90b6;
  --track: #f4f4f7;
  --focus: #e68aaf;
  --danger-bg: #fdeaea;
  --danger-line: #f0b8b8;
  --danger-text: #c0392b;
  --ok: #41876e;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
button:disabled { cursor: default; opacity: .6; }
a { color: var(--pink); }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Shell ---------- */
.sidebar {
  width: 236px;
  position: fixed;
  inset: 0 auto 0 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 28px 20px 0;
  display: flex;
  flex-direction: column;
  z-index: 50;
}
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; text-decoration: none; padding: 0 8px; }
.brand img { width: 128px; height: auto; display: block; }
.brand-name { color: #fff; font-size: 17px; font-weight: 650; letter-spacing: -.3px; }
.brand-name small { display: block; font-size: 11px; font-weight: 500; letter-spacing: 2px; color: #8e94a2; text-transform: uppercase; margin-top: 2px; }
.workspace { font-size: 11px; font-weight: 700; letter-spacing: 1.8px; color: #747b8b; margin: 36px 13px 12px; text-transform: uppercase; }
.sidebar nav { display: block; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 13px; margin-bottom: 6px;
  color: var(--sidebar-text); background: transparent; border: 0; border-radius: 7px;
  font-size: 14px; text-decoration: none; text-align: left;
}
.nav-item:hover { background: #ffffff0d; }
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-text); }
.nav-item svg { flex-shrink: 0; }
.profile {
  margin: auto -20px 0;
  padding: 18px 20px;
  border-top: 1px solid #ffffff12;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: #e3e5eb;
}
.profile-text { min-width: 0; }
.profile-text strong { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-text small { display: block; color: #7f8797; font-size: 12px; }
.profile button {
  margin-left: auto; flex-shrink: 0;
  background: none; border: 1px solid #ffffff22; border-radius: 6px;
  color: #c3c8d4; font-size: 12px; font-weight: 600; padding: 6px 10px;
}
.profile button:hover { border-color: var(--pink); color: #ff90b6; }

.main { margin-left: 236px; min-height: 100vh; }
.topbar {
  height: 69px; padding: 0 37px;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--muted);
}
.topbar strong { font-weight: 500; color: #343945; }
.topbar .slash { margin: 0 12px; color: #c1c3c9; }
.topbar-status { display: flex; align-items: center; gap: 7px; }
.topbar-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--pink); }
.content { max-width: 1600px; margin: 0 auto; padding: 32px 37px 40px; }
.content.narrow { max-width: 1040px; }

.page-heading { margin-bottom: 24px; }
.eyebrow { font-size: 12px; letter-spacing: 1.7px; color: #868b95; font-weight: 650; text-transform: uppercase; }
h1 { font-size: 33px; font-weight: 650; letter-spacing: -1.3px; line-height: 1.3; margin: 4px 0; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.15px; }
.lede { font-size: 14px; color: var(--muted); }

/* ---------- Panels, buttons, forms ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.panel-pad { padding: 22px 24px; }
.panel-title { font-size: 13px; font-weight: 650; margin-bottom: 14px; }
.panel-title.rule { font-size: 15px; padding-bottom: 14px; margin-bottom: 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-block; text-decoration: none; text-align: center;
  background: #fff; color: #444b56;
  border: 1px solid #dedfe5; border-radius: 6px;
  padding: 9px 16px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.btn:hover { border-color: #c4c7d0; color: var(--ink); }
.btn-primary { background: var(--pink); border-color: var(--pink); color: #fff; }
.btn-primary:hover { background: #c4235f; border-color: #c4235f; color: #fff; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #343945; border-color: #343945; color: #fff; }
.btn-outline-pink { color: var(--pink); border-color: var(--pink); }
.btn-outline-pink:hover { background: var(--pink-soft); color: var(--pink); border-color: var(--pink); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.field-label { display: block; font-size: 12px; font-weight: 600; color: #757b87; margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; min-width: 0;
  border: 1px solid #e1e3e8; border-radius: 6px; background: #fff;
  color: var(--ink); padding: 0 10px; height: 38px; font-size: 14px;
}
.input::placeholder, .textarea::placeholder { color: #aab0ba; }
.textarea { height: auto; padding: 11px 12px; line-height: 1.6; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--pink); box-shadow: 0 0 0 3px rgba(223,47,114,.12); }
.select { cursor: pointer; }

.alert { display: none; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--danger-bg); border: 1px solid var(--danger-line); border-radius: 9px; padding: 14px 18px; margin-bottom: 18px; font-size: 14px; font-weight: 600; color: var(--danger-text); }

/* ---------- Dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 17px; margin-bottom: 20px; }
.stat { padding: 18px 20px; }
.stat-title { font-size: 13px; color: #6e7480; }
.stat-value { font-size: 34px; font-weight: 600; letter-spacing: -1px; line-height: 1.15; margin: 8px 0 2px; }
.stat-value.pink { color: var(--pink); }
.stat-note { font-size: 12px; color: #8b909a; }

.breakdowns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 25px; }
.breakdowns .panel { padding: 19px 22px; }
.bars { display: flex; flex-direction: column; gap: 11px; }
.bar-row { display: flex; align-items: center; gap: 12px; font-size: 12px; color: #646b77; }
.bar-label { width: 160px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { flex: 1; height: 8px; background: var(--track); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .4s ease; }
.bar-count { width: 28px; text-align: right; font-weight: 600; color: #3d424c; }
.bars-empty { font-size: 13px; color: #959aa3; padding: 8px 0; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 13px; padding: 20px 23px; border-bottom: 1px solid var(--line); }
.filters > .f-search { flex: 2; min-width: 240px; }
.filters > .f-sel { flex: 1; min-width: 160px; }
.filters > .f-date { min-width: 150px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search-wrap .input { padding-left: 34px; }
.check { display: flex; align-items: center; gap: 8px; height: 38px; cursor: pointer; white-space: nowrap; font-size: 13px; font-weight: 600; color: #666d78; }
.check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--pink); }

.ledger-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; padding: 22px 23px 18px; }
.ledger-head h2 { display: flex; align-items: center; gap: 10px; }
.ledger-hint { font-size: 12px; color: #959aa3; }
#cm-result-label { color: #b7426e; background: #fbedf3; border-radius: 5px; padding: 2px 8px; font-size: 12px; font-weight: 600; }

.table-scroll { max-height: 62vh; overflow: auto; border-top: 1px solid var(--line); }
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll::-webkit-scrollbar-thumb { background: #dcdee4; border-radius: 5px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
table.ledger { width: 100%; min-width: 1020px; border-collapse: collapse; text-align: left; }
.ledger thead th { position: sticky; top: 0; z-index: 2; background: #fafbfc; color: #838996; font-size: 12px; font-weight: 500; padding: 12px 15px; border-bottom: 1px solid var(--line); text-align: left; }
.ledger th:first-child, .ledger td:first-child { padding-left: 23px; }
.ledger th:last-child, .ledger td:last-child { padding-right: 23px; text-align: right; }
.cm-row { cursor: pointer; border-bottom: 1px solid #f0f1f4; }
.cm-row:hover { background: #fdfbfc; }
.cm-row td { padding: 15px; font-size: 13px; color: #737a85; vertical-align: middle; }
.cm-row.archived { opacity: .55; }
.cm-ref { font: 600 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: #515866; white-space: nowrap; }
.cm-tag-archived { color: #959aa3; font: 600 10px Inter, sans-serif; letter-spacing: .8px; margin-left: 4px; }
.cm-desc { color: #383e49; line-height: 1.5; max-width: 380px; }
.nowrap { white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; padding: 4px 9px; border-radius: 4px; background: #f2f3f6; color: #656d7c; border: 1px solid transparent; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.reporter-flag { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; }
.reporter-flag .dot { width: 7px; height: 7px; border-radius: 50%; }

.empty { text-align: center; padding: 56px 26px; }
.empty h3 { font-size: 16px; font-weight: 650; margin-bottom: 6px; }
.empty p { color: var(--muted); margin-bottom: 16px; }
.footnote { margin-top: 20px; font-size: 12px; color: #9298a2; text-align: center; }

/* ---------- Case view ---------- */
.back-link { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; text-decoration: none; margin-bottom: 20px; }
.case-header { background: var(--sidebar); border-radius: 9px; padding: 28px 32px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 18px; color: #fff; }
.case-header .label { font-size: 12px; font-weight: 600; color: var(--sidebar-text); text-transform: uppercase; letter-spacing: 1.4px; margin-bottom: 8px; }
.case-ref { font: 650 32px/1.1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: -1px; color: #ff90b6; margin-bottom: 14px; }
.case-header .right { text-align: right; }
.case-date { font-size: 18px; font-weight: 600; }
.case-time { font-size: 13px; color: var(--sidebar-text); margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 5px 12px; border-radius: 5px; }
.case-section { padding: 26px 32px; margin-bottom: 16px; }
.kv-grid { display: grid; gap: 18px 32px; margin-bottom: 22px; }
.kv-grid.two { grid-template-columns: 1fr 1fr; }
.kv-grid.three { grid-template-columns: 1fr 1fr 1fr; margin-bottom: 0; }
.kv-label { font-size: 12px; font-weight: 600; color: #838996; margin-bottom: 5px; }
.kv-value { font-size: 15px; font-weight: 500; }
.block { margin-bottom: 22px; }
.block:last-child { margin-bottom: 0; }
.text-box { background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px; font-size: 14px; color: #383e49; line-height: 1.75; white-space: pre-wrap; }
.muted-note { font-size: 13px; color: #959aa3; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: 10px 14px; }
.file-name { font-size: 14px; color: #383e49; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { display: flex; align-items: center; gap: 14px; flex-shrink: 0; font-size: 12px; color: #959aa3; }
.note { background: #fafbfc; border: 1px solid var(--line); border-radius: 6px; padding: 13px 16px; }
.note-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.note-author { font-size: 13px; font-weight: 600; color: var(--pink-text); }
.note-when { font-size: 12px; color: #959aa3; }
.note-text { font-size: 14px; color: #383e49; line-height: 1.7; white-space: pre-wrap; }
.status-saved { display: none; align-items: center; gap: 7px; color: var(--ok); font-size: 13px; font-weight: 600; padding: 10px 0; }
.anon-box { display: none; background: #f2f3f6; border-radius: 6px; padding: 16px 18px; font-size: 14px; color: #656d7c; font-weight: 500; }
.state-card { padding: 56px 32px; text-align: center; }
.state-card h3 { font-size: 18px; font-weight: 650; margin-bottom: 6px; }
.state-card p { color: var(--muted); margin-bottom: 20px; }

/* ---------- Attachments gallery ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }
.g-tile { margin: 0; min-width: 0; }
.g-thumb { position: relative; display: block; width: 100%; aspect-ratio: 4 / 3; padding: 0; background: #fafbfc; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.g-thumb:hover { border-color: var(--pink); }
.g-preview { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }
.g-preview img, .g-preview video { width: 100%; height: 100%; object-fit: cover; display: block; transition: filter .2s; }
.g-preview canvas { max-width: 100%; max-height: 100%; object-fit: contain; display: block; background: #fff; box-shadow: 0 1px 4px #0002; }
.gallery.blurred .g-preview img, .gallery.blurred .g-preview video, .gallery.blurred .g-preview canvas { filter: blur(22px) saturate(.6); }
.g-icon { display: flex; flex-direction: column; align-items: center; gap: 8px; color: #9aa0ab; }
.g-ext { font-size: 12px; font-weight: 650; letter-spacing: 1px; color: #656d7c; background: #eef0f4; border-radius: 4px; padding: 2px 8px; }
.g-play { position: absolute; right: 8px; bottom: 8px; width: 28px; height: 28px; border-radius: 50%; background: #171b24cc; color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; padding-left: 2px; }
.g-pages { position: absolute; right: 8px; bottom: 8px; background: #171b24cc; color: #fff; font-size: 11px; font-weight: 600; border-radius: 4px; padding: 2px 7px; }
.g-tile figcaption { padding: 7px 2px 0; min-width: 0; }
.g-name { display: block; font-size: 13px; color: #383e49; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-size { display: block; font-size: 12px; color: #959aa3; }
.g-notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--pink-soft); border: 1px solid #f5d3e1; border-radius: 6px; padding: 9px 14px; margin-bottom: 14px; font-size: 13px; color: #93445f; }
.g-viewer { border: 0; border-radius: 12px; padding: 0; width: min(1100px, calc(100% - 32px)); height: min(86vh, 860px); margin: auto; background: var(--sidebar); color: #fff; overflow: hidden; }
.g-viewer[open] { display: flex; flex-direction: column; }
.g-viewer::backdrop { background: #0c0f16d9; }
.g-viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #ffffff1a; font-size: 13px; }
.g-viewer-bar #g-viewer-caption { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-viewer-actions { display: flex; gap: 8px; flex-shrink: 0; }
.g-viewer-stage { flex: 1; min-height: 0; display: flex; align-items: center; gap: 8px; padding: 12px; }
.g-viewer-body { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: center; }
.g-viewer-body img, .g-viewer-body video { max-width: 100%; max-height: 100%; object-fit: contain; }
.g-loading { color: var(--sidebar-text); font-size: 14px; }
.g-nav { flex-shrink: 0; width: 40px; height: 56px; border: 0; border-radius: 8px; background: #ffffff14; color: #fff; font-size: 28px; line-height: 1; }
.g-nav:hover { background: #ffffff26; }
@media (max-width: 520px) { .gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; } .g-nav { width: 30px; } }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 24px; background: var(--sidebar); }
.login-card { background: #fff; border-radius: 14px; padding: 40px 40px 32px; width: 100%; max-width: 420px; box-shadow: 0 24px 100px #00000055; }
.login-head { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 28px; }
.login-head img { width: 132px; height: auto; margin-bottom: 14px; }
.login-head h1 { font-size: 26px; letter-spacing: -.8px; margin: 0 0 6px; }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form .btn { width: 100%; padding: 12px; font-size: 15px; }
.login-error { display: none; background: var(--danger-bg); border: 1px solid var(--danger-line); border-radius: 6px; padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--danger-text); text-align: center; }
.login-foot { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); text-align: center; font-size: 12px; color: #959aa3; line-height: 1.6; }
.login-legal { margin-top: 22px; font-size: 12px; color: #747b8b; }

/* ---------- Responsive ---------- */
@media (max-width: 1150px) {
  .sidebar { width: 205px; padding-left: 14px; padding-right: 14px; }
  .main { margin-left: 205px; }
  .content { padding: 26px 22px; }
  .topbar { padding: 0 22px; }
  .stats { gap: 10px; }
  .stat { padding: 14px; }
}
@media (max-width: 800px) {
  .sidebar { position: relative; width: auto; padding: 14px 18px; flex-direction: row; align-items: center; gap: 14px; flex-wrap: wrap; }
  .brand { flex-direction: row; text-align: left; padding: 0; }
  .brand img { width: 48px; }
  .workspace { display: none; }
  .sidebar nav { display: flex; gap: 8px; }
  .nav-item { width: auto; margin: 0; padding: 8px 12px; font-size: 13px; }
  .profile { margin: 0 0 0 auto; padding: 0; border: 0; }
  .profile-text { display: none; }
  .main { margin: 0; }
  .topbar { height: 48px; }
  .content { padding: 22px 18px; }
  h1 { font-size: 29px; }
  .breakdowns { gap: 12px; }
  .kv-grid.three { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .breakdowns { grid-template-columns: 1fr; }
  .filters { padding: 16px; }
  .filters > .f-search { flex-basis: 100%; }
  .bar-label { width: 120px; }
  .case-section { padding: 20px 18px; }
  .case-header { padding: 22px 20px; }
  .case-header .right { text-align: left; }
  .kv-grid.two { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px 26px; }
}
