/* Sakan Tradelinks tracker. One plain stylesheet, no build step.
   Colours are variables at the top, change them there. */
:root {
  --side-bg: #e7f0ff;
  --side-line: #cfe0f7;
  --side-text: #2b4a73;
  --side-hover: #d3e4ff;
  --ink-blue: #17345c;
  --blue: #2563eb;
  --blue-soft: #e4edff;
  --bg: #f3f7fd;
  --card: #ffffff;
  --line: #e2e7f0;
  --text: #1a2233;
  --muted: #6a7488;
  --green: #12794a;   --green-soft: #e3f5ec;
  --amber: #a15c00;   --amber-soft: #fff1d6;
  --red: #b42318;     --red-soft: #fde8e6;
  --violet: #5b3fc4;  --violet-soft: #ece8fb;
  --grey-soft: #eceff4;
  --radius: 12px;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--muted); font-size: .9em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pre { white-space: pre-wrap; }
.center { text-align: center; }
.empty { padding: 22px 20px; color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: .82rem; margin-top: 4px; font-weight: 400; }

/* ---- layout ---- */
.shell { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 24px 28px 48px; max-width: 1280px; width: 100%; }

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--side-bg); color: var(--side-text);
  border-right: 1px solid var(--side-line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 22px 20px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--blue); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 1.2rem;
}
.brand-name { font-weight: 700; font-size: .98rem; color: var(--ink-blue); }
.brand-sub { font-size: .75rem; color: #5b7a9f; }
.nav { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 9px;
  color: var(--side-text); font-weight: 500; text-decoration: none;
}
.nav-link:hover { background: var(--side-hover); color: var(--ink-blue); text-decoration: none; }
.nav-link.active { background: var(--blue); color: #fff; }
.nav-badge {
  margin-left: auto; background: #ef4444; color: #fff; border-radius: 999px;
  font-size: .72rem; padding: 1px 8px; font-weight: 700;
}
.nav-small { font-size: .9rem; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--side-line); }
.icon { width: 20px; height: 20px; flex: none; }
.scrim { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 12px 28px; min-height: 60px;
}
.topbar-title { font-size: 1.15rem; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.icon-btn {
  background: none; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px;
  display: grid; place-items: center; cursor: pointer; color: var(--text); position: relative; list-style: none;
}
.icon-btn::-webkit-details-marker { display: none; }
.menu-btn { display: none; }

/* bell */
.bell { position: relative; }
.bell-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--amber); color: #fff; font-size: .72rem; font-weight: 700;
  display: grid; place-items: center;
}
.bell-badge.red { background: #dc2626; }
.bell-panel {
  position: absolute; right: 0; top: 48px; width: 340px; max-width: calc(100vw - 24px);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(37, 99, 235, .16); padding: 10px;
}
.bell-panel h4 { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 8px 4px; }
.bell-item { display: block; padding: 8px; border-radius: 8px; color: var(--text); }
.bell-item:hover { background: var(--bg); text-decoration: none; }
.bell-item span { display: block; color: var(--muted); font-size: .85rem; }
.bell-all { display: block; text-align: center; padding: 10px; border-top: 1px solid var(--line); margin-top: 6px; font-weight: 600; }

/* ---- flash ---- */
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: var(--green-soft); color: var(--green); }
.flash-error { background: var(--red-soft); color: var(--red); }

/* ---- stats ---- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  color: var(--text); display: block; border-top: 4px solid var(--blue);
}
.stat:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(37, 99, 235, .10); }
.stat-violet { border-top-color: #7c5cdb; }
.stat-amber { border-top-color: #f59e0b; }
.stat-red { border-top-color: #dc2626; }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat-num { font-size: 2.1rem; font-weight: 800; line-height: 1.2; margin: 2px 0; }
.stat-sub { color: var(--muted); font-size: .8rem; }

/* ---- panels ---- */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; margin-bottom: 20px; }
.grid2 > .panel { margin-bottom: 0; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.panel-body { padding: 16px 20px; }
.panel-foot { padding: 12px 20px; border-top: 1px solid var(--line); background: #fafbfd; }
.link-all { font-weight: 600; font-size: .9rem; white-space: nowrap; }
.form-panel { max-width: 820px; }
.page-actions { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.page-h2 { font-size: 1.4rem; }
.crumbs { color: var(--muted); font-size: .88rem; margin-bottom: 8px; }
.result-count { margin: -4px 0 10px; }
.count-pill {
  min-width: 36px; text-align: center; padding: 4px 12px; border-radius: 999px; font-weight: 700;
  background: var(--grey-soft); color: var(--muted);
}
.count-red { background: var(--red-soft); color: var(--red); }
.count-amber { background: var(--amber-soft); color: var(--amber); }

/* ---- reminders list ---- */
.rem-list { list-style: none; margin: 0; padding: 0; }
.rem {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.rem:last-child { border-bottom: 0; }
.rem-client { font-weight: 700; color: var(--text); }
.rem-sub { color: var(--muted); font-size: .88rem; }
.rem-sub a { color: var(--muted); }
.rem-meta { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.rem-date { font-size: .88rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rem-meta .late, .rem-meta .soon { font-size: .86rem; }
.late { color: var(--red); font-weight: 600; }
.soon { color: var(--amber); font-weight: 600; }
.rem-act { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.jump { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.jump-chip { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; color: var(--text); font-weight: 600; font-size: .88rem; }
.jump-chip:hover { text-decoration: none; border-color: var(--blue); }
.jump-chip span { margin-left: 6px; color: var(--muted); }
.jump-red { background: var(--red-soft); border-color: transparent; }
.jump-red span { color: var(--red); }
.jump-amber { background: var(--amber-soft); border-color: transparent; }
.jump-amber span { color: var(--amber); }

/* ---- chips, badges, buttons ---- */
.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600;
  white-space: nowrap; background: var(--grey-soft); color: var(--muted);
}
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-amber { background: var(--amber-soft); color: var(--amber); }
.chip-red { background: var(--red-soft); color: var(--red); }
.chip-blue { background: var(--blue-soft); color: var(--blue); }
.chip-violet { background: var(--violet-soft); color: var(--violet); }
.chip-grey { background: var(--grey-soft); color: var(--muted); }
.badge { font-size: .78rem; font-weight: 600; }
.badge-ok { color: var(--green); }
.badge-pending { color: var(--muted); }

.btn {
  display: inline-block; background: var(--blue); color: #fff; border: 1px solid var(--blue); border-radius: 9px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; text-align: center; white-space: nowrap;
}
.btn:hover { background: #1a43b8; text-decoration: none; }
.btn-sm { padding: 5px 12px; font-size: .85rem; }
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { color: var(--red); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--blue); cursor: pointer; list-style: none; }
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--red); }
summary.btn-link::-webkit-details-marker { display: none; }
form { margin: 0; }
form.inline { display: inline; }

/* ---- forms ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; flex: 1; min-width: 0; }
.toolbar input[type=search] { flex: 1 1 260px; min-width: 0; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=date],
input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid #cfd6e4;
  border-radius: 9px; padding: 9px 12px;
}
.toolbar select { width: auto; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9db8ff; border-color: var(--blue); }
.form { padding: 18px 20px 20px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid label, label.check { font-weight: 600; font-size: .9rem; display: block; }
.form-grid label > input, .form-grid label > select, .form-grid label > textarea { margin-top: 6px; font-weight: 400; }
.span2 { grid-column: span 2; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
input[type=file] { display: block; width: 100%; margin-top: 6px; font: inherit; }
label.check { font-weight: 500; margin-top: 14px; display: flex; gap: 8px; align-items: flex-start; }
label.check input { width: auto; margin-top: 4px; }
.panel-body > .form { padding: 0; }

/* ---- tables (become stacked cards on phones) ---- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 11px 16px; background: #fafbfd; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table th.num { text-align: right; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.cell-main strong { color: var(--text); }
td.actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
td.actions form { display: inline; }

/* ---- detail pages ---- */
.info { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; margin: 0; padding: 18px 20px; }
.info dt { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.info dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.info .span2 { grid-column: span 2; }
.inline-details > summary { cursor: pointer; display: inline-block; list-style: none; }
.inline-details[open] > summary { margin-bottom: 8px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input { flex: 1 1 200px; width: auto; }
.add-box { border-top: 1px solid var(--line); }
.add-box > summary { padding: 14px 20px; cursor: pointer; font-weight: 600; color: var(--blue); }
.add-box[open] > summary { border-bottom: 1px solid var(--line); }

.timeline, .file-list, .feed { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 14px 20px; border-top: 1px solid var(--line); }
.tl-head { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tl-body { margin-top: 6px; white-space: pre-wrap; }
.tl-foot { margin-top: 6px; }
.file-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 13px 20px; border-top: 1px solid var(--line); }
.panel-body + .timeline li:first-child, .panel-body + .file-list li:first-child { border-top: 1px solid var(--line); }

.feed-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.feed-entity { font-weight: 600; font-size: .85rem; }
.feed-time { margin-left: auto; color: var(--muted); font-size: .82rem; }
.feed-label { margin-top: 3px; overflow-wrap: anywhere; }
.feed-changes { list-style: none; margin: 6px 0 0; padding: 8px 12px; background: var(--bg); border-radius: 8px; font-size: .86rem; }
.feed-changes li { padding: 1px 0; overflow-wrap: anywhere; }
.fc-field { font-weight: 600; margin-right: 4px; }
.fc-field::after { content: ":"; }
.fc-old { color: var(--red); text-decoration: line-through; text-decoration-color: rgba(180, 35, 24, .4); }
.fc-new { color: var(--green); font-weight: 600; }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; margin-top: 8px; }

/* ---- tablet & phone ---- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid2 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 8px 0 32px rgba(23, 52, 92, .18); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(23, 52, 92, .35); z-index: 35; }
  .menu-btn { display: grid; }
  .topbar { padding: 10px 14px; }
  .topbar-title { font-size: 1.05rem; }
  .content { padding: 16px 14px 40px; }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-num { font-size: 1.7rem; }
  .form-grid, .info { grid-template-columns: 1fr; }
  .span2, .info .span2 { grid-column: auto; }
  .rem { grid-template-columns: 1fr; gap: 8px; padding: 14px 16px; }
  .rem-act { flex-direction: row; align-items: center; justify-content: space-between; }
  .toolbar select, .toolbar .btn { flex: 1 1 auto; }
  .page-actions .btn-row { width: 100%; }
  .panel-head { padding: 14px 16px; }
  .form, .info { padding: 16px; }
  .timeline li, .file-list li { padding: 12px 16px; }

  /* tables turn into stacked cards */
  .table.stack thead { display: none; }
  .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
  .table.stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.stack td { padding: 4px 0; border: 0; display: flex; justify-content: space-between; gap: 14px; text-align: right; }
  .table.stack td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; flex: none; }
  .table.stack td.cell-main { display: block; text-align: left; padding-bottom: 8px; }
  .table.stack td.cell-main::before { display: none; }
  .table.stack td.actions { justify-content: flex-start; padding-top: 8px; }
  .table.stack td.actions::before { display: none; }
  .table.stack td.num { text-align: right; }
}
