:root {
  --navy: #0a2c3d;
  --navy-2: #0e3d52;
  --teal: #125a73;
  --sky: #1a7a96;
  --rust: #c65a18;
  --orange: #e07a12;
  --amber: #f09a18;
  --gold: #f5b020;
  --ink: #0a2c3d;
  --muted: #5a6d78;
  --line: #d5dde1;
  --paper: #f3f1ec;
  --card: #fffcf8;
  --sidebar: #0a2c3d;
  --sidebar-2: #0e3d52;
  --accent: #e07a12;
  --accent-2: #1a7a96;
  --warn: #c65a18;
  --ok: #1a7a96;
  --info: #125a73;
  --shadow: 0 10px 30px rgba(10, 44, 61, 0.08);
  --r: 14px;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --ui: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
}

.app { display: flex; min-height: 100%; }
.sidebar {
  width: 248px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #efe8dc;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  flex-shrink: 0;
}
.palette {
  display: flex; height: 5px; border-radius: 99px; overflow: hidden;
  margin: 0 8px 16px;
}
.palette i { flex: 1; }
.palette i:nth-child(1) { background: #0a2c3d; }
.palette i:nth-child(2) { background: #0e3d52; }
.palette i:nth-child(3) { background: #125a73; }
.palette i:nth-child(4) { background: #1a7a96; }
.palette i:nth-child(5) { background: #c65a18; }
.palette i:nth-child(6) { background: #e07a12; }
.palette i:nth-child(7) { background: #f09a18; }
.palette i:nth-child(8) { background: #f5b020; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 22px; }
.brand .mark {
  width: 42px; height: 42px; border-radius: 50%;
  object-fit: cover; background: #0b2a3d;
  flex-shrink: 0;
}
.brand strong { display: block; font-size: 13.5px; letter-spacing: .01em; }
.brand em { font-style: normal; font-size: 11px; color: #b7c0c8; }

nav { display: flex; flex-direction: column; gap: 4px; }
nav button, .ghost {
  appearance: none; border: 0; background: transparent;
  color: #d7dde3; text-align: left; padding: 9px 12px;
  border-radius: 10px; cursor: pointer; font: inherit;
}
nav button:hover, .ghost:hover { background: rgba(255,255,255,.07); }
nav button.active { background: #efe8dc; color: var(--ink); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; }
.ghost { width: 100%; color: #c9d1d8; }
.hint { color: #8b97a3; font-size: 11px; line-height: 1.4; margin: 10px 4px 0; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 28px 8px;
}
.top h1 { font-family: var(--font); font-size: 28px; font-weight: 600; margin: 0; flex: 1; }
.menu { display: none; }
.content { padding: 8px 28px 40px; }

.grid { display: grid; gap: 14px; }
.kpi { grid-template-columns: repeat(3, 1fr); }
.kpi-2 { grid-template-columns: 1fr 1fr; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card.blue { background: #eef4f8; }
.card.green { background: #eef6f2; }
.card.lilac { background: #f3eef6; }
.card.warn { background: #f8eee9; }
.card h3 { margin: 0 0 6px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.kpi .num, .kpi-2 .num, .card > .num { font-family: var(--font); font-size: 28px; }
table.sales { font-size: 14px; }
table.sales td { font-size: 14px; }
.card p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input, select, textarea, button.btn {
  font: inherit; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink);
}
input, select, textarea { padding: 9px 11px; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
.search { flex: 1; min-width: 200px; }
#stockIsbn {
  width: 100%;
  font-size: 22px;
  letter-spacing: .06em;
  padding: 14px 16px;
}
button.btn {
  padding: 9px 14px; cursor: pointer; background: var(--ink); color: #fff; border-color: var(--ink);
}
button.btn.secondary { background: #fff; color: var(--ink); }
button.btn.accent { background: var(--accent); border-color: var(--accent); }
button.btn.ok { background: var(--accent-2); border-color: var(--accent-2); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
table.fixed { table-layout: fixed; width: 100%; }
table.sales td.num { text-align: right; white-space: nowrap; }
tr.dim { opacity: .55; }
tr.clickable, .clickable { cursor: pointer; }
tr.clickable:hover { background: #f7f1e6; }
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: #ece4d6; font-size: 12px; margin: 0 4px 4px 0;
  border: 0; font-family: inherit; color: inherit;
}
.tag.ok { background: #d7ead8; }
.tag.warn { background: #f6e2c4; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
button.btn.tiny { padding: 5px 9px; font-size: 12px; }
.sales-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
button.linkish {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  font: inherit; font-size: 12px; padding: 0 0 0 8px; text-decoration: underline;
}
button.tag:hover { background: #dce8f2; }
.tag.sf { background: #dce8f2; }
.tag.phil { background: #efe6c9; }
.muted { color: var(--muted); }
.empty {
  padding: 48px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--r); background: rgba(255,255,255,.4);
}
.empty strong { display: block; color: var(--ink); font-family: var(--font); font-size: 22px; margin-bottom: 8px; }

.kasa { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.kasa-side { display: grid; gap: 16px; }
.kasa > .card .pick-list { max-height: 160px; }
.dash-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.authors-grid { grid-template-columns: 1fr 1fr; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.filters select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font: inherit; }
.alpha-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.alpha-bar button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font: inherit;
}
.alpha-bar button.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.pick-list { max-height: 220px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.pick-list button {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; padding: 10px 12px; cursor: pointer; font: inherit;
}
.pick-list button:last-child { border-bottom: 0; }
.pick-list button:hover { background: #f7f1e6; }
.chosen {
  margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: #e8f3f6; border: 1px solid #b7d4de;
}
.sync-ok { color: var(--sky); }
.sync-off { color: var(--rust); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
label.field { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.total { font-family: var(--font); font-size: 26px; margin: 8px 0 14px; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(28,25,20,.35);
  display: none; align-items: flex-start; justify-content: center;
  padding: 8vh 16px; z-index: 20;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--card); border-radius: 16px; width: min(640px, 100%);
  padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.18);
  max-height: 84vh; overflow: auto;
}
.modal h2 { font-family: var(--font); margin: 0 0 14px; }

.drawer-bg { display: none; }
.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff;
  padding: 10px 14px; border-radius: 10px; display: none; z-index: 30;
}
.toast.show { display: block; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 15;
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .sidebar.open { transform: none; }
  .menu { display: inline-flex; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 10px; cursor: pointer; }
  .drawer-bg.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 14; }
  .kpi, .kpi-2, .kasa, .row-2, .row-3, .dash-split, .authors-grid { grid-template-columns: 1fr; }
  .content, .top { padding-left: 16px; padding-right: 16px; }
  .top h1 { font-size: 22px; }
}
