:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #1c2434;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2456e6;
  --brand-dark: #1a41ad;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- app shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: #10192e; color: #cbd5e1; padding: 18px 12px;
  flex-shrink: 0; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .logo {
  color: #fff; font-weight: 700; font-size: 17px; padding: 6px 10px 16px;
  letter-spacing: .2px;
}
.sidebar .logo span { color: #7ea2ff; }
.sidebar a.nav {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 8px; color: #cbd5e1; font-size: 14px;
}
.sidebar a.nav:hover { background: #1c2a4a; text-decoration: none; color: #fff; }
.sidebar a.nav.active { background: var(--brand); color: #fff; }
.sidebar .sect {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px;
  color: #64748b; padding: 14px 10px 4px;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 10px 18px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-weight: 600; font-size: 16px; flex: 1; }
.burger {
  display: none; background: none; border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 18px; cursor: pointer;
}
.content { padding: 18px; max-width: 1100px; width: 100%; margin: 0 auto; }

.badge-dot {
  background: var(--err); color: #fff; border-radius: 99px; font-size: 11px;
  padding: 1px 7px; margin-left: auto;
}
.userchip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--brand);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; flex-shrink: 0;
}

/* ---- components ---- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.stat { text-align: left; }
.stat .num { font-size: 26px; font-weight: 700; }
.stat .lbl { color: var(--muted); font-size: 12.5px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase;
     letter-spacing: .4px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block; padding: 2px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill.pending   { background: #fef3c7; color: #92400e; }
.pill.in_progress, .pill.ordered { background: #dbeafe; color: #1e40af; }
.pill.delivered { background: #ede9fe; color: #5b21b6; }
.pill.approved, .pill.issued, .pill.received, .pill.active, .pill.ok, .pill.income
  { background: #dcfce7; color: #166534; }
.pill.returned, .pill.rejected, .pill.cancelled, .pill.disabled, .pill.expense, .pill.overdue
  { background: #fee2e2; color: #991b1b; }
.pill.low, .pill.draft { background: #f1f5f9; color: #475569; }
.pill.pending_approval { background: #fef3c7; color: #92400e; }
.pill.expired { background: #ffedd5; color: #9a3412; }
.pill.terminated { background: #fee2e2; color: #991b1b; }
.pill.completed, .pill.paid { background: #dcfce7; color: #166534; }
.pill.normal { background: #e0f2fe; color: #075985; }
.pill.high { background: #ffedd5; color: #9a3412; }
.pill.urgent { background: #fee2e2; color: #991b1b; }

button, .btn {
  background: var(--brand); border: none; color: #fff; font: inherit;
  font-weight: 600; font-size: 14px; padding: 9px 16px; border-radius: 8px;
  cursor: pointer; display: inline-block;
}
button:hover, .btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.ghost:hover { background: #eef2ff; }
.btn.sm { padding: 5px 11px; font-size: 13px; }
.btn.ok { background: var(--ok); }
.btn.danger { background: var(--err); }
.btn.warn { background: var(--warn); }

label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid #bfd0ff; border-color: var(--brand);
}
textarea { min-height: 90px; resize: vertical; }
form.inline { display: inline; }
.formrow { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.flash.ok    { background: #dcfce7; color: #166534; }
.flash.warn  { background: #fef3c7; color: #92400e; }
.flash.error { background: #fee2e2; color: #991b1b; }

.tabs { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a {
  padding: 7px 14px; border-radius: 99px; font-size: 13.5px; font-weight: 600;
  color: var(--muted); background: #e9edf5;
}
.tabs a.active { background: var(--brand); color: #fff; }
.tabs a:hover { text-decoration: none; }

.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 26px 0; font-size: 14px; }
.page-head { display: flex; align-items: center; justify-content: space-between;
             gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line);
               margin-left: 6px; position: relative; }
.timeline li::before {
  content: ""; width: 10px; height: 10px; background: var(--brand);
  border-radius: 50%; position: absolute; left: -6px; top: 15px;
}

.memo-body { white-space: pre-wrap; line-height: 1.7; }
.loginbox { max-width: 400px; margin: 7vh auto; padding: 0 16px; }
.loginbox .logo { text-align: center; font-size: 22px; font-weight: 700; margin-bottom: 18px; }
.loginbox .logo span { color: var(--brand); }

/* ---- auth pages / mobile ---- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease; height: 100%;
  }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .burger { display: block; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .formrow { grid-template-columns: 1fr; }
  .content { padding: 14px 12px; }
  .userchip .uname { display: none; }
}
