:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --panel2: #232d3a;
  --border: #2e3b4a;
  --text: #e8eef4;
  --muted: #9aabbc;
  --accent: #f59e0b;
  --accent2: #38bdf8;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --pro: #a78bfa;
  --radius: 10px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; }
a { color: var(--accent2); }
header.app-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #1c2530, #141a21);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #d97706);
  display: grid; place-items: center; font-weight: 800; color: #111; font-size: 14px;
}
.brand h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.02em; }
.brand .sub { margin: 0; color: var(--muted); font-size: 0.8rem; }
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 600;
  border: 1px solid var(--border); background: var(--panel);
}
.badge.free { color: var(--good); }
.badge.pro { color: var(--pro); border-color: #5b4b8a; background: #241f36; }
.badge.pro-tag {
  color: var(--pro); border-color: #5b4b8a; background: #2a2340;
  font-size: 0.65rem; padding: 2px 6px; vertical-align: middle; margin-left: 6px;
}
button, .btn {
  appearance: none; border: 1px solid var(--border); background: var(--panel2);
  color: var(--text); border-radius: 8px; padding: 8px 12px; font: inherit;
  font-size: 0.9rem; cursor: pointer;
}
button:hover, .btn:hover { border-color: var(--accent2); }
button.primary { background: var(--accent); color: #111; border-color: #d97706; font-weight: 700; }
button.primary:hover { filter: brightness(1.05); }
button.ghost { background: transparent; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
main { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 980px) { main { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.panel h2 { margin: 0 0 10px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.panel h3 { margin: 14px 0 8px; font-size: 0.9rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select, .field textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font: inherit; min-width: 0;
}
.field textarea { font-family: var(--mono); font-size: 0.85rem; width: 100%; min-height: 90px; }
.field.grow { flex: 1; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
tr:hover td { background: rgba(255,255,255,0.02); }
.muted { color: var(--muted); }
.ok { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat { background: var(--panel2); border-radius: 8px; padding: 10px; border: 1px solid var(--border); }
.stat .v { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; }
.locked {
  position: relative; border: 1px dashed #5b4b8a; border-radius: 8px; padding: 12px;
  background: rgba(167,139,250,0.06);
}
.locked .lock-note { font-size: 0.85rem; color: var(--pro); margin: 0 0 8px; }
.bar-viz { display: flex; height: 18px; border-radius: 4px; overflow: hidden; background: #0b1015; border: 1px solid var(--border); margin-top: 4px; }
.bar-viz .cut { background: var(--accent2); border-right: 1px solid #0b1015; }
.bar-viz .kerf { background: #475569; }
.bar-viz .off { background: #334155; }
.toast {
  position: fixed; bottom: 16px; right: 16px; background: #123; color: #fff;
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--accent2);
  display: none; z-index: 50; max-width: 360px;
}
.toast.show { display: block; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: none;
  align-items: center; justify-content: center; z-index: 40; padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; width: min(440px, 100%);
}
.modal h3 { margin-top: 0; }
.footer-note {
  max-width: 1400px; margin: 0 auto 24px; padding: 0 16px;
  font-size: 0.75rem; color: var(--muted);
}
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; }
  header.app-header, .no-print, .toast, .modal-backdrop { display: none !important; }
  main { display: block; padding: 0; }
  .panel { border: none; background: #fff; page-break-inside: avoid; }
  .print-only { display: block; }
  a { color: #000; text-decoration: none; }
  th, td { border-bottom: 1px solid #ccc; }
}
