:root {
  --dark: #17202b;
  --ink: #101828;
  --muted: #64748b;
  --line: #d9e2ec;
  --soft: #f4f7fb;
  --blue: #0e4c92;
  --cyan: #0aa6c8;
  --red: #d72638;
  --green: #0f9364;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Segoe UI, Arial, sans-serif; color: var(--ink); background: #eef3f7; }
button, input, select, textarea { font: inherit; }
button { border: 0; border-radius: 6px; background: var(--blue); color: white; font-weight: 700; padding: 10px 14px; cursor: pointer; }
button.secondary { background: #e7ecf2; color: var(--ink); }
button.danger { background: var(--red); }
input, select, textarea { width: 100%; border: 1px solid #cfd8e3; border-radius: 6px; padding: 10px 11px; background: white; }
textarea { min-height: 84px; resize: vertical; }
label { display: block; color: #475569; font-size: 13px; font-weight: 700; margin: 8px 0 4px; }

.sidebar { position: fixed; inset: 0 auto 0 0; width: 245px; background: var(--dark); color: white; padding: 24px 18px; display: flex; flex-direction: column; gap: 8px; }
.brand-logo { width: 175px; height: 66px; object-fit: contain; object-position: left center; margin-bottom: 8px; }
.sidebar span { color: #a7b2c0; text-transform: uppercase; font-size: 12px; letter-spacing: .08em; }
.sidebar nav { display: grid; gap: 7px; margin-top: 20px; }
.sidebar nav button { text-align: left; background: transparent; color: #dbe5ef; padding: 12px; }
.sidebar nav button.active, .sidebar nav button:hover { background: var(--blue); color: white; }
.logout { margin-top: auto; color: #dbe5ef; text-decoration: none; padding: 10px 12px; border-radius: 6px; }
.logout:hover { background: #263241; }

.app { margin-left: 245px; min-height: 100vh; padding: 26px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 32px; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
.user-chip { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 9px 14px; font-weight: 700; }
.view { display: none; }
.view.active { display: block; }
.hero { background: white; border: 1px solid var(--line); border-radius: 8px; padding: 18px; margin-bottom: 16px; }
.hero img { height: 80px; max-width: 340px; object-fit: contain; }
.stats { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat, .panel { background: white; border: 1px solid var(--line); border-radius: 8px; }
.stat { padding: 18px; }
.stat span { display: block; color: var(--muted); font-weight: 700; font-size: 13px; }
.stat strong { display: block; margin-top: 8px; font-size: 27px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.split { display: grid; grid-template-columns: minmax(420px, 1.05fr) minmax(430px, .95fr); gap: 16px; align-items: start; }
.panel { padding: 18px; overflow: auto; }
.panel h2 { margin: 0 0 14px; font-size: 20px; }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar input { max-width: 560px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full, #budget-form .full, #delivery-form .full { grid-column: 1 / -1; }
.wide-editor { min-width: 580px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { background: var(--dark); color: white; text-align: left; padding: 10px; white-space: nowrap; }
td { border-bottom: 1px solid #edf1f5; padding: 9px 10px; vertical-align: top; }
tr.selected td { background: #ddecfb; }
tr:hover td { background: #f6f9fc; }
.items { margin: 12px 0; }
.items input { min-width: 80px; padding: 8px; }
.item-actions { display: flex; gap: 8px; margin-bottom: 8px; }
.totals { display: flex; justify-content: end; font-weight: 800; color: var(--blue); margin: 10px 0; }
.hint { color: var(--muted); }
.separator { height: 1px; background: var(--line); margin: 18px 0; }
#toast { position: fixed; right: 18px; bottom: 18px; background: var(--ink); color: white; padding: 13px 16px; border-radius: 7px; opacity: 0; transform: translateY(10px); transition: .2s; }
#toast.show { opacity: 1; transform: translateY(0); }
.alert { padding: 12px; border-radius: 7px; margin: 12px 0; font-weight: 700; }
.alert.danger { background: #fde1e4; color: #8a1420; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #17202b, #0e4c92); }
.login-card { width: min(420px, calc(100vw - 28px)); background: white; border-radius: 8px; padding: 28px; box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.login-logo { width: 230px; height: 74px; object-fit: contain; object-position: left center; }
.login-card h1 { margin: 8px 0 0; }
.login-card p { margin: 6px 0 18px; color: var(--muted); }
.login-card button { width: 100%; margin-top: 14px; }
.login-card small { display: block; color: var(--muted); margin-top: 14px; }

@media (max-width: 1100px) {
  .sidebar { position: static; width: auto; min-height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { display: flex; margin: 0; }
  .brand-logo, .sidebar span, .logout { display: none; }
  .app { margin-left: 0; padding: 16px; }
  .stats, .grid.two, .split { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
}
