:root {
  --primary: #4457ff;
  --primary-2: #596aff;
  --pink: #ff5f85;
  --yellow: #ffc147;
  --ink: #0b0a33;
  --text: #3e395f;
  --muted: #7a7d9c;
  --line: #d9dbe9;
  --soft: #f3f5ff;
  --panel: #ffffff;
  --bg: #f7f8ff;
  --good: #16a34a;
  --bad: #dc2626;
  --shadow: 0 18px 55px rgba(68, 87, 255, .12);
  --radius: 8px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--primary); text-decoration: none; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
label { display: grid; gap: 7px; color: var(--ink); font-weight: 700; font-size: 14px; }
small { display: block; color: var(--muted); margin-top: 3px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid #eff0f6; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .02em; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar { background: var(--ink); color: #fff; padding: 22px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), var(--pink)); color: white; font-weight: 900; }
.brand strong { display: block; color: #fff; }
.brand small { color: #e1e4ff; }
.brand-login { margin-bottom: 20px; }
.nav { display: grid; gap: 6px; }
.nav a { color: #e1e4ff; padding: 11px 12px; border-radius: var(--radius); font-weight: 700; }
.nav a.active, .nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.main { min-width: 0; padding: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 22px; }
.topbar h1 { margin: 0; color: var(--ink); font-size: 34px; line-height: 1.2; }
.eyebrow { margin: 0 0 4px; color: var(--primary); font-size: 13px; text-transform: uppercase; font-weight: 900; letter-spacing: .08em; }

.panel, .metric-card {
  background: var(--panel);
  border: 1px solid #eff0f6;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel { padding: 20px; margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; color: var(--ink); font-size: 20px; }
.panel-head.sub { margin-top: 26px; padding-top: 18px; border-top: 1px solid #eff0f6; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.metric-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric-card { padding: 20px; position: relative; overflow: hidden; }
.metric-card::after { content: ""; position: absolute; inset: auto -25px -45px auto; width: 110px; height: 110px; border-radius: 50%; background: var(--soft); }
.metric-card span { display: block; color: var(--muted); font-weight: 800; margin-bottom: 8px; }
.metric-card strong { display: block; color: var(--ink); font-size: 28px; line-height: 1.1; }
.metric-card small { font-weight: 700; }
.accent-blue::after { background: rgba(68,87,255,.14); }
.accent-pink::after { background: rgba(255,95,133,.14); }
.accent-yellow::after { background: rgba(255,193,71,.2); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.tool-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) 360px; gap: 20px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; align-items: end; }
.form-grid.compact { grid-template-columns: repeat(6, minmax(130px, 1fr)); }
.span-2 { grid-column: span 2; }
.inline-form { display: flex; gap: 10px; align-items: end; margin-bottom: 14px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

.button { border: 0; border-radius: var(--radius); padding: 11px 15px; font-weight: 900; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-height: 42px; }
.button-primary { background: var(--primary); color: white; box-shadow: 0 12px 26px rgba(68,87,255,.25); }
.button-secondary { background: var(--soft); color: var(--primary); }
.button-ghost { background: white; color: var(--ink); border: 1px solid var(--line); }
.button-small { min-height: 34px; padding: 7px 10px; font-size: 13px; }
.full { width: 100%; }
.icon-button, .icon-danger { border: 0; background: transparent; cursor: pointer; }
.icon-danger { color: var(--bad); font-weight: 900; font-size: 20px; }

.notice { padding: 12px 14px; background: #e1e4ff; border: 1px solid #c8ceff; color: var(--ink); border-radius: var(--radius); margin-bottom: 16px; font-weight: 800; }
.notice-error { background: #fff1f4; border-color: #ffc3d1; }
.form-error { color: var(--bad); font-weight: 800; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 900; color: var(--primary); background: var(--soft); }
.badge.good { color: #166534; background: #dcfce7; }
.badge.bad { color: #991b1b; background: #fee2e2; }
.good-text { color: var(--good); font-weight: 900; }
.bad-text { color: var(--bad); font-weight: 900; }
.muted, .empty { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.actions-cell { display: flex; gap: 8px; align-items: center; justify-content: flex-end; min-width: 210px; }
.actions-cell form { margin: 0; }
.row-editor { position: relative; }
.row-editor summary { cursor: pointer; color: var(--primary); font-weight: 900; }
.row-editor form { position: absolute; right: 0; z-index: 5; width: 320px; display: grid; gap: 8px; padding: 12px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--radius); }
.stack-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.stack-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 0; border-bottom: 1px solid #eff0f6; }
.stack-list em { color: var(--muted); font-style: normal; font-size: 12px; }
.quantity { display: inline-grid; place-items: center; min-width: 40px; height: 32px; background: var(--soft); color: var(--primary); border-radius: var(--radius); font-weight: 900; }

.line-items { display: grid; gap: 10px; }
.line-item { display: grid; grid-template-columns: repeat(6, minmax(90px, 1fr)) 34px; gap: 8px; align-items: center; }
.line-item .wide { grid-column: span 2; }
.total-box { margin-top: 16px; border-top: 1px solid #eff0f6; padding-top: 16px; display: flex; justify-content: space-between; font-size: 18px; color: var(--ink); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day-card { min-height: 112px; background: white; border: 1px solid #eff0f6; border-radius: var(--radius); padding: 10px; }
.day-card.today { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(68,87,255,.12); }
.event { margin-top: 8px; padding: 7px; background: var(--soft); border-radius: var(--radius); color: var(--ink); font-weight: 800; }

.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at top left, #e1e4ff, transparent 35%), var(--bg); padding: 20px; }
.login-card { width: min(420px, 100%); background: white; border: 1px solid #eff0f6; border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.login-card h1 { color: var(--ink); margin: 0 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-card input { margin-bottom: 12px; }

.mobile-only { display: none; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 280px; transform: translateX(-100%); transition: transform .2s ease; z-index: 20; }
  .sidebar.show { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .metric-grid, .grid-2, .tool-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .main { padding: 18px; }
  .topbar h1 { font-size: 26px; }
  .form-grid, .form-grid.compact, .line-item, .calendar-grid { grid-template-columns: 1fr; }
  .inline-form, .actions-cell, .panel-head { align-items: stretch; flex-direction: column; }
  .span-2, .line-item .wide { grid-column: auto; }
}
