/* AudioLine Tāme — Apple-style UI, light + dark */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, Consolas, "JetBrains Mono", monospace;

  --bg: #f5f5f7;
  --bg2: #ececf0;
  --surface: #ffffff;
  --surface2: #f7f7f9;
  --surface3: #ededf0;
  --border: rgba(0, 0, 0, 0.08);
  --border2: rgba(0, 0, 0, 0.14);
  --text: #1d1d1f;
  --text2: #6e6e73;
  --text3: #a1a1a6;
  --accent: #7d2f3a;
  --accent-h: #6a2531;
  --accent-soft: rgba(125, 47, 58, 0.09);
  --accent-soft2: rgba(125, 47, 58, 0.16);
  --accent-text: #7d2f3a;
  --blue: #0071e3;
  --green: #1f9d55;
  --green-soft: rgba(52, 199, 89, 0.14);
  --orange: #c77700;
  --orange-soft: rgba(255, 159, 10, 0.16);
  --red: #d93025;
  --red-soft: rgba(255, 59, 48, 0.12);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.16);
  --glass: rgba(255,255,255,.72);
  --radius: 12px;
  --radius-sm: 8px;
  --sel-bg: rgba(125, 47, 58, 0.07);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg2: #0d0d0f;
  --surface: #1c1c1e;
  --surface2: #232326;
  --surface3: #2c2c2e;
  --border: rgba(255, 255, 255, 0.09);
  --border2: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --text2: #98989d;
  --text3: #636366;
  --accent: #b5505d;
  --accent-h: #c65d6b;
  --accent-soft: rgba(181, 80, 93, 0.16);
  --accent-soft2: rgba(181, 80, 93, 0.26);
  --accent-text: #e0808c;
  --blue: #0a84ff;
  --green: #30d158;
  --green-soft: rgba(48, 209, 88, 0.16);
  --orange: #ffa02e;
  --orange-soft: rgba(255, 159, 10, 0.18);
  --red: #ff453a;
  --red-soft: rgba(255, 69, 58, 0.16);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.6);
  --glass: rgba(28,28,30,.72);
  --sel-bg: rgba(181, 80, 93, 0.12);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; font-size: 14px; line-height: 1.4; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
input, textarea, select { background: var(--surface); border: 1px solid var(--border2); border-radius: var(--radius-sm); padding: 7px 10px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,113,227,.18); }
input[type=number] { font-family: var(--mono); font-variant-numeric: tabular-nums; }
input::placeholder { color: var(--text3); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(127,127,127,.35); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(127,127,127,.55); background-clip: content-box; border: 2px solid transparent; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text2); }
.faint { color: var(--text3); }
.hidden { display: none !important; }

/* ── App shell ── */
#root, .app { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 18px; height: 56px; flex-shrink: 0;
  background: var(--glass); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border); position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand img { height: 26px; width: auto; display: block; }
:root[data-theme="dark"] .brand img { filter: invert(1); }
.brand .sub { color: var(--text2); font-weight: 500; }

.seg { display: inline-flex; background: var(--surface3); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: none; background: transparent; padding: 5px 14px; border-radius: 7px; font-weight: 500; color: var(--text2); transition: all .15s; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
:root[data-theme="dark"] .seg button.on { background: #3a3a3c; }
:root[data-theme="dark"] .modal { background: #2c2c2e; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border2); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 9px; font-weight: 500; line-height: 1.2; transition: background .12s, transform .05s, border-color .12s; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-h); }
.btn.blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text2); }
.btn.ghost:hover { background: var(--surface3); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.xs { padding: 3px 8px; font-size: 12px; border-radius: 7px; }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.icon { padding: 6px 8px; }
.iconbtn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn { border: none; background: transparent; color: var(--text2); width: 30px; height: 30px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; }
.iconbtn:hover { background: var(--surface3); color: var(--text); }

.savestate { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text2); padding: 4px 10px; border-radius: 20px; background: var(--surface3); }
.savestate .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.savestate.dirty .dot { background: var(--orange); }
.savestate.saving .dot { background: var(--blue); animation: pulse 1s infinite; }
.savestate.error .dot { background: var(--red); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .3 } }

.main { flex: 1; min-height: 0; display: flex; }

/* ── Projects list ── */
.sidebar { width: 220px; flex-shrink: 0; padding: 16px 12px; border-right: 1px solid var(--border); background: var(--bg); overflow-y: auto; }
.sidebar h4 { margin: 8px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); font-weight: 600; }
.folder { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; cursor: pointer; color: var(--text); font-weight: 500; }
.folder:hover { background: var(--surface3); }
.folder.on { background: var(--accent-soft); color: var(--accent-text); }
.folder .n { margin-left: auto; font-size: 12px; color: var(--text3); font-family: var(--mono); }
.folder.on .n { color: var(--accent-text); }
.folder .ic { width: 18px; text-align: center; }

.content { flex: 1; min-width: 0; overflow-y: auto; padding: 22px 28px 60px; }
.content-inner { max-width: 1080px; margin: 0 auto; }
.pagehead { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.pagehead h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.pagehead .grow { flex: 1; }
.search { position: relative; }
.search input { width: 280px; padding-left: 32px; border-radius: 10px; background: var(--surface); }
.search:before { content: "⌕"; position: absolute; left: 11px; top: 50%; transform: translateY(-55%); color: var(--text3); font-size: 16px; }

.plist { display: flex; flex-direction: column; gap: 8px; }
.prow { display: grid; grid-template-columns: 1fr auto auto auto auto; align-items: center; gap: 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; cursor: pointer; transition: box-shadow .15s, transform .1s, border-color .15s; }
.prow:hover { box-shadow: var(--shadow); border-color: var(--border2); }
.prow .t { font-size: 15px; font-weight: 600; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.prow .d { color: var(--text2); font-size: 13px; margin-top: 3px; }
.prow .date { font-size: 13px; color: var(--text2); min-width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.prow .vers { font-size: 12px; color: var(--text3); min-width: 70px; text-align: right; }
.prow .sum { font-family: var(--mono); font-size: 16px; font-weight: 600; min-width: 110px; text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; letter-spacing: .01em; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.gray { background: var(--surface3); color: var(--text2); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.blue { background: rgba(0,113,227,.12); color: var(--blue); }
.empty { text-align: center; padding: 80px 20px; color: var(--text3); }
.empty .big { font-size: 44px; opacity: .35; margin-bottom: 10px; }

/* ── Menus ── */
.menuwrap { position: relative; display: inline-block; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.menu.left { right: auto; left: 0; }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; border: none; background: transparent; padding: 8px 10px; border-radius: 8px; color: var(--text); font-size: 13px; }
.menu button:hover { background: var(--surface3); }
.menu button.danger { color: var(--red); }
.menu button:disabled { opacity: .4; }
.menu .sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu .ic { width: 18px; text-align: center; opacity: .8; }

/* ── Editor ── */
.editor { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.ehead { padding: 12px 20px 10px; background: var(--bg); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.ehead .row1 { display: flex; align-items: center; gap: 12px; }
.ehead .row1 .name { flex: 1; font-size: 20px; font-weight: 700; letter-spacing: -.02em; background: transparent; border: 1px solid transparent; padding: 4px 8px; margin-left: -8px; }
.ehead .row1 .name:hover { border-color: var(--border2); }
.ehead .row1 .name:focus { background: var(--surface); }
.ehead .row2 { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); font-weight: 600; }
.field input { padding: 6px 9px; }
.field.grow { flex: 1; min-width: 160px; }

.versions { display: flex; align-items: center; gap: 6px; padding: 8px 20px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; }
.versions .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); font-weight: 600; margin-right: 6px; }
.vchip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 20px; border: 1px solid var(--border2); background: var(--surface); font-size: 13px; font-weight: 500; white-space: nowrap; cursor: pointer; color: var(--text2); }
.vchip:hover { background: var(--surface2); }
.vchip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.vchip .star { color: var(--orange); }
.vchip .chk { color: var(--green); }
.vchip.on .star, .vchip.on .chk { filter: brightness(1.15); }
.vchip .num { font-family: var(--mono); font-size: 11px; opacity: .7; }

.ebody { flex: 1; min-height: 0; display: flex; }
.picker { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cattabs { display: flex; gap: 2px; padding: 6px 14px 0; border-bottom: 1px solid var(--border); overflow-x: auto; flex-shrink: 0; background: var(--bg); }
.cattabs button { border: none; background: transparent; padding: 8px 11px 9px; font-size: 12px; font-weight: 600; color: var(--text2); border-bottom: 2px solid transparent; white-space: nowrap; letter-spacing: .02em; display: inline-flex; align-items: center; gap: 5px; }
.cattabs button:hover { color: var(--text); }
.cattabs button.on { color: var(--accent-text); border-bottom-color: var(--accent); }
.cattabs .cnt { font-size: 10px; background: var(--accent); color: #fff; padding: 1px 6px; border-radius: 10px; font-family: var(--mono); }
.searchrow { padding: 10px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0; display: flex; gap: 8px; }
.searchrow input { flex: 1; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.items { flex: 1; overflow-y: auto; padding: 4px 20px 100px; }
.subhead { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); font-weight: 700; padding: 16px 0 4px; border-bottom: 1px solid var(--border); margin-bottom: 2px; display: flex; align-items: center; gap: 8px; }
.subhead .lv { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text3); }
.item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin: 1px -8px; border-radius: 8px; border-bottom: 1px solid transparent; }
.item:hover { background: var(--surface2); }
.item.sel { background: var(--sel-bg); }
.item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.item.sel .nm { font-weight: 500; color: var(--accent-text); }
.item .price { font-family: var(--mono); font-size: 12.5px; color: var(--text2); width: 78px; text-align: right; font-variant-numeric: tabular-nums; cursor: text; border-radius: 6px; padding: 3px 6px; }
.item .price:hover { background: var(--surface3); }
.item .price.ov { color: var(--orange); font-weight: 600; }
.item input.price { width: 78px; text-align: right; padding: 3px 6px; border: 1px solid var(--border2); background: var(--surface); }
.item .tag { font-size: 10px; color: var(--text3); background: var(--surface3); padding: 1px 6px; border-radius: 6px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border2); border-radius: 8px; overflow: hidden; background: var(--surface); flex-shrink: 0; }
.qty button { width: 28px; height: 28px; border: none; background: transparent; color: var(--text2); font-size: 16px; line-height: 1; }
.qty button:hover { background: var(--surface3); color: var(--text); }
.qty input { width: 40px; height: 28px; border: none; border-left: 1px solid var(--border); border-right: 1px solid var(--border); border-radius: 0; text-align: center; padding: 0; font-weight: 600; background: transparent; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty input:focus { box-shadow: none; }
.addrow { display: flex; align-items: center; gap: 6px; padding: 5px 0 6px; }
.addrow .open { border: none; background: transparent; color: var(--text3); font-size: 12.5px; padding: 4px 0; display: inline-flex; gap: 5px; align-items: center; }
.addrow .open:hover { color: var(--accent-text); }
.addrow input { padding: 5px 9px; font-size: 13px; }
.addrow input.nm { flex: 1; }
.addrow input.pr { width: 80px; text-align: right; }
.addrow .hint { font-size: 11px; color: var(--text3); }

.summary { width: 360px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; }
.summary .shead { padding: 12px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.summary .shead b { font-size: 13px; }
.summary .slist { flex: 1; overflow-y: auto; padding: 4px 18px 10px; }
.scat { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); font-weight: 700; padding: 12px 0 3px; display: flex; justify-content: space-between; }
.scat .mono { text-transform: none; letter-spacing: 0; }
.sitem { display: flex; align-items: center; gap: 7px; padding: 4px 0; font-size: 12.5px; border-bottom: 1px solid var(--border); }
.sitem .q { font-family: var(--mono); color: var(--accent-text); font-weight: 600; min-width: 26px; }
.sitem .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text2); }
.sitem .t { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sitem .x { color: var(--text3); border: none; background: transparent; padding: 0 4px; font-size: 13px; }
.sitem .x:hover { color: var(--red); }
.totals { padding: 14px 18px 16px; border-top: 1px solid var(--border); background: var(--surface2); }
.trow { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 13px; }
.trow .l { color: var(--text2); display: flex; align-items: center; gap: 5px; }
.trow .l small { color: var(--text3); font-size: 11px; }
.trow .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.trow input { width: 70px; text-align: right; padding: 4px 8px; }
.trow.disc .v { color: var(--red); }
.trow.grand { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border2); font-size: 17px; font-weight: 700; }
.trow.grand .v { color: var(--accent-text); }
.tbtns { display: flex; gap: 8px; margin-top: 14px; }
.tbtns .btn { flex: 1; justify-content: center; }
.notes textarea { width: 100%; min-height: 54px; resize: vertical; font-size: 12.5px; }

/* ── Catalog view ── */
.cat-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cat-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface2); }
.cat-table td { padding: 5px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.cat-table tr:last-child td { border-bottom: none; }
.cat-table tr.subrow td { background: var(--surface2); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text3); font-weight: 700; padding: 10px 12px 4px; }
.cat-table input { padding: 4px 8px; width: 100%; background: transparent; border-color: transparent; }
.cat-table input:hover { border-color: var(--border2); }
.cat-table input:focus { background: var(--surface); }
.cat-table input.pr { width: 90px; text-align: right; }
.cat-table tr.hid td { opacity: .45; }
.cat-table td.act { white-space: nowrap; text-align: right; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.formrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }

/* ── Modal ── */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 100; animation: fade .12s; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.modal { background: var(--surface); border: 1px solid var(--border2); border-radius: 16px; box-shadow: var(--shadow-lg); width: 420px; max-width: 92vw; padding: 22px 22px 18px; animation: pop .15s; }
@keyframes pop { from { transform: scale(.96); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -.01em; }
.modal p { margin: 0 0 16px; color: var(--text2); font-size: 13.5px; line-height: 1.5; }
.modal .mbtns { display: flex; justify-content: flex-end; gap: 8px; }
.modal input, .modal select { width: 100%; margin-bottom: 12px; }
.modal label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 4px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 20px; font-size: 13px; box-shadow: var(--shadow-lg); z-index: 200; animation: fade .15s; }
.loading { height: 100vh; display: flex; align-items: center; justify-content: center; color: var(--text3); flex-direction: column; gap: 10px; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border2); border-top-color: var(--text2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
kbd { font-family: var(--mono); font-size: 11px; background: var(--surface3); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border2); }

@media (max-width: 980px) {
  .summary { width: 300px; }
  .sidebar { width: 180px; }
}
@media (max-width: 760px) {
  .ebody { flex-direction: column; }
  .summary { width: auto; border-left: none; border-top: 1px solid var(--border); max-height: 45vh; }
  .main { flex-direction: column; }
  .sidebar { width: auto; display: flex; gap: 4px; padding: 8px; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .sidebar h4 { display: none; }
  .prow { grid-template-columns: 1fr auto; }
  .prow .vers, .prow .date { display: none; }
}
