:root {
  --bg: #080d14;
  --panel: #101923;
  --panel-2: #151f2b;
  --text: #f4f7fb;
  --muted: #a7b3c3;
  --line: #293646;
  --accent: #38bdf8;
  --accent-dark: #0f6f94;
  --danger: #fb7185;
  --ok: #34d399;
}
* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at top left, #1e3a52 0, #080d14 38%, #05070b 100%); color: var(--text); font-family: Arial, Helvetica, sans-serif; font-size: 15px; }
button, input { font: inherit; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; gap: 20px; align-items: center; padding: 18px clamp(14px, 3vw, 34px); background: rgba(8, 13, 20, 0.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2 { margin: 0; line-height: 1.05; }
h1 { font-size: clamp(28px, 4vw, 48px); }
h2 { font-size: 22px; }
.muted { color: var(--muted); }
.shell { width: min(1500px, 100%); margin: 0 auto; padding: 18px clamp(12px, 2.5vw, 28px) 40px; display: grid; gap: 18px; }
.panel { background: rgba(16, 25, 35, .94); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: 0 22px 60px rgba(0, 0, 0, .32); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.setup-grid, .entry-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
label { display: grid; gap: 6px; color: #d9e3ee; font-size: 13px; font-weight: 800; }
input { min-height: 42px; border: 1px solid var(--line); border-radius: 10px; background: #0b121b; color: var(--text); padding: 9px 11px; outline: none; }
input[readonly] { color: #c8d3df; background: #111b26; }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56, 189, 248, .18); }
button, .button-link { min-height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #172331; color: var(--text); cursor: pointer; font-weight: 800; padding: 8px 14px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.button-link.small { min-height: 32px; padding: 6px 10px; font-size: 13px; }
button:hover { border-color: var(--accent); }
button.primary, .primary { background: linear-gradient(135deg, var(--accent), var(--accent-dark)); border-color: transparent; color: #031018; }
button.danger { color: #fecdd3; border-color: #7f1d1d; background: #45131c; }
.setup-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.supplier-manager { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.supplier-chip { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; background: #0b121b; font-size: 13px; }
.supplier-chip button { min-height: 26px; padding: 0 7px; border-radius: 999px; color: var(--danger); }
.search-label { position: relative; grid-column: span 1; }
.search-menu { position: absolute; top: 68px; left: 0; right: 0; z-index: 10; max-height: 310px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: #0b121b; box-shadow: 0 18px 40px rgba(0,0,0,.38); }
.search-option { width: 100%; display: block; text-align: left; border: 0; border-bottom: 1px solid #1f2c3a; border-radius: 0; background: transparent; padding: 10px 12px; }
.search-option.active, .search-option:hover { background: #173044; border-color: #255a75; }
.search-option strong { display: block; }
.reference-line { color: var(--muted); margin-top: 10px; font-size: 13px; }
.bill-info-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.bill-info-grid div { border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); padding: 10px; }
.bill-info-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.bill-info-grid strong { display: block; font-size: 14px; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1000px; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 8px; text-align: left; vertical-align: top; }
th { color: #dce9f5; background: #172331; position: sticky; top: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
.item-main { font-weight: 800; }
.item-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 20; background: #e0f2fe; color: #031018; border-radius: 14px; padding: 12px 14px; box-shadow: 0 18px 40px rgba(0,0,0,.32); }
@media print {
  .topbar, .entry-panel, #billsTable, #newBillBtn, .setup-actions, .supplier-manager, .toast { display: none !important; }
  body { background: #fff; color: #000; font-family: Arial, Helvetica, sans-serif; }
  .shell { padding: 0; }
  .panel { box-shadow: none; border: 0; padding: 8px; background: #fff; color: #000; }
  table { font-size: 10px; min-width: 0; }
  th, td { padding: 4px; color: #000; border-color: #999; }
  th { background: #eee; }
}
@media (max-width: 900px) {
  body { font-size: 14px; }
  .topbar { align-items: stretch; flex-direction: column; gap: 12px; padding: 14px; position: static; }
  .top-actions, .setup-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .top-actions > *, .setup-actions > * { width: 100%; }
  h1 { font-size: 28px; }
  h2 { font-size: 20px; }
  .shell { padding: 12px 10px 28px; gap: 12px; }
  .panel { border-radius: 14px; padding: 14px; }
  .setup-grid, .entry-grid, .bill-info-grid { grid-template-columns: 1fr; gap: 10px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  input, button, .button-link { min-height: 46px; font-size: 16px; }
  .search-menu { position: fixed; top: auto; left: 10px; right: 10px; bottom: 12px; max-height: min(58vh, 420px); border-radius: 16px; }
  .search-option { padding: 13px 14px; }
  .reference-line { line-height: 1.5; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; border-collapse: separate; border-spacing: 0 10px; }
  thead { display: none; }
  tbody, tr, td { display: block; width: 100%; }
  tr { border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2); padding: 8px 10px; }
  td { display: grid; grid-template-columns: minmax(100px, 42%) 1fr; gap: 10px; align-items: center; border-bottom: 1px solid #253242; padding: 9px 0; }
  td:last-child { border-bottom: 0; }
  td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
  td.num { text-align: left; white-space: normal; }
  td[data-label="Action"] { grid-template-columns: 1fr; }
  td[data-label="Action"]::before { display: none; }
  td[data-label="Action"] button, td[data-label="Action"] .button-link { width: 100%; }
  .item-main, .item-sub { overflow-wrap: anywhere; }
  .toast { left: 10px; right: 10px; bottom: 10px; text-align: center; }
}
@media (min-width: 901px) and (max-width: 1180px) {
  .setup-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .entry-grid { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .bill-info-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .eyebrow { font-size: 11px; }
  h1 { font-size: 24px; }
  .panel { padding: 12px; }
  td { grid-template-columns: 1fr; gap: 3px; }
}
