/* PakkaBill v0.3 — Seller application design system (branch pakkabill-v0.3).
   Navy/orange brand. Type scale, spacing scale, components, responsive shell.
   Breakpoints: desktop > 1100 · tablet 768–1100 · mobile < 768. */

:root {
  --navy: #12336b; --navy-dark: #0e2a5c; --navy-soft: #eef2f9;
  --orange: #f4560f; --orange-soft: #fff1e8;
  --green: #1e8e4e; --green-soft: #e7f5ec;
  --red: #b91c1c; --red-soft: #fdecea;
  --amber: #b45309; --amber-soft: #fef3e2;
  --ink: #1c2733; --muted: #64748b; --line: #e2e8f0; --bg: #f5f7fb;
  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 30px rgba(16, 24, 40, .12);
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 15px; --fs-md: 17px; --fs-lg: 20px; --fs-xl: 25px; --fs-2xl: 31px;
  --side-w: 236px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  background: var(--bg); color: var(--ink); font-size: var(--fs-base); line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--navy); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }

:focus-visible { outline: 2.5px solid var(--orange); outline-offset: 2px; border-radius: 4px; }

/* ------------------------------------------------------------- app shell */
.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.app-side {
  background: var(--navy-dark); color: #cfd8e8;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 18px 14px 22px;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.side-brand img { height: 40px; border-radius: 8px; background: #fff; padding: 2px; }
.side-brand .t { font-weight: 800; color: #fff; font-size: var(--fs-md); letter-spacing: .2px; }
.side-brand .s { font-size: var(--fs-xs); color: #93a4c2; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-group { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: #7e91b3; padding: 16px 10px 6px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: var(--radius-sm); color: inherit; text-decoration: none;
  font-size: var(--fs-sm); font-weight: 500; border: 0; background: none; width: 100%;
  cursor: pointer; text-align: left; transition: background .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-item.active { background: var(--orange); color: #fff; font-weight: 700; }
.nav-item .ic { width: 20px; text-align: center; font-size: 15px; }
.side-foot { margin-top: auto; padding: 14px 10px 0; font-size: var(--fs-xs); color: #93a4c2; }

.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar2 {
  display: flex; align-items: center; gap: 14px; padding: 0 28px; height: 64px;
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar2 .who { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: var(--fs-sm); }
.topbar2 .seller-name { font-weight: 700; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 18px; cursor: pointer; }

.content { width: 100%; max-width: 1200px; margin: 0 auto; padding: 28px 28px 64px; }
.section { display: none; }
.section.active { display: block; }
.section-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.section-head h1 { font-size: var(--fs-xl); }
.section-head .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: 4px; }
.section-head .actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------------------------------------- cards */
.s-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.s-card + .s-card { margin-top: 18px; }
.s-card h2 { font-size: var(--fs-md); margin-bottom: 4px; }
.s-card .card-sub { color: var(--muted); font-size: var(--fs-sm); margin-bottom: 16px; }

.s-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.s-grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .lbl { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.stat-card .num { font-size: var(--fs-2xl); font-weight: 800; color: var(--navy-dark); margin: 6px 0 2px; letter-spacing: -.5px; }
.stat-card .hint { font-size: var(--fs-xs); color: var(--muted); }
.stat-card.accent .num { color: var(--orange); }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--navy); color: #fff; border: 1px solid var(--navy);
  padding: 10px 18px; border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 600;
  cursor: pointer; text-decoration: none; min-height: 42px; transition: filter .15s;
}
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: var(--orange); border-color: var(--orange); }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: var(--fs-xs); }
.btn-lg { min-height: 50px; padding: 13px 26px; font-size: var(--fs-base); }
.btn[disabled] { opacity: .55; cursor: not-allowed; filter: none; }

/* ------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .err { font-size: var(--fs-xs); color: var(--red); font-weight: 600; }
input, select, textarea {
  font: inherit; font-size: var(--fs-base); width: 100%; min-height: 42px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: #b8c4d8; }
input.invalid, select.invalid { border-color: var(--red); background: var(--red-soft); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

/* ------------------------------------------------------------- tables */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.s-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.s-table th {
  text-align: left; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 2px solid var(--line);
  white-space: nowrap; background: #fbfcfe;
}
.s-table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.s-table tbody tr:hover { background: #f8fafc; }
.s-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.s-table .actions-cell { text-align: right; white-space: nowrap; }
.s-table .actions-cell .btn { margin-left: 6px; }
.cell-main { font-weight: 600; }
.cell-sub { font-size: var(--fs-xs); color: var(--muted); }

/* ------------------------------------------------------------- badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: 999px; font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.wait { background: var(--amber-soft); color: var(--amber); }
.badge.no { background: var(--red-soft); color: var(--red); }
.badge.neutral { background: var(--navy-soft); color: var(--navy); }

/* ------------------------------------------------------------- states */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .big { font-size: 34px; margin-bottom: 10px; }
.empty .t { font-weight: 700; color: var(--ink); font-size: var(--fs-md); margin-bottom: 4px; }
.loading-line { height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eef1f6, #e2e8f0, #eef1f6); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.alert { border-radius: var(--radius-sm); padding: 12px 16px; font-size: var(--fs-sm); margin: 14px 0; border: 1px solid; }
.alert.ok { background: var(--green-soft); border-color: #bfe6cc; color: #14532d; }
.alert.no { background: var(--red-soft); border-color: #f3c1c1; color: #7f1d1d; }
.alert.info { background: var(--navy-soft); border-color: #cdd8ec; color: var(--navy-dark); }

/* ------------------------------------------------------------- guided tour */
.tour-overlay { position: fixed; inset: 0; z-index: 200; }
.tour-box {
  position: fixed; border-radius: 10px; outline: 3px solid var(--orange);
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, .58); pointer-events: none; transition: all .25s ease;
}
.tour-tip {
  position: fixed; background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg);
  padding: 18px 18px 14px; z-index: 201;
}
.tour-step { font-size: var(--fs-xs); font-weight: 800; color: var(--orange); text-transform: uppercase; letter-spacing: .06em; }
.tour-tip h3 { margin: 6px 0; font-size: var(--fs-md); }
.tour-tip p { margin: 0; color: var(--muted); font-size: var(--fs-sm); line-height: 1.55; }
.tour-actions { display: flex; gap: 8px; margin-top: 14px; align-items: center; }

/* ------------------------------------------------------------- toast + modal */
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 100; background: var(--navy-dark); color: #fff;
  padding: 13px 18px; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm); font-weight: 600; opacity: 0; transform: translateY(8px);
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: 380px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { background: var(--green); }
.toast.no { background: var(--red); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; padding: 24px; }
.modal h3 { font-size: var(--fs-md); margin-bottom: 10px; }
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ------------------------------------------------------------- chart + misc */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding: 12px 4px 0; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; min-width: 0; }
.chart .bar { width: 100%; max-width: 46px; border-radius: 6px 6px 2px 2px; background: var(--navy); min-height: 2px; }
.chart .bar.zero { background: var(--line); }
.chart .bar.future { background: repeating-linear-gradient(45deg, #e8edf5, #e8edf5 4px, #f4f7fb 4px, #f4f7fb 8px); }
.chart .bar-lbl { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.chart .bar-val { font-size: var(--fs-xs); color: var(--ink); font-weight: 700; }

.kv { display: grid; grid-template-columns: 190px 1fr; gap: 8px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 500; }

.progress { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: var(--navy); border-radius: 999px; }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; max-width: 100vw; }
  .app-side {
    position: sticky; top: 0; height: auto; z-index: 30; padding: 10px 12px;
    flex-direction: row; align-items: center; gap: 8px; overflow: hidden; min-width: 0;
  }
  .side-brand { padding: 0 6px 0 0; flex: 0 0 auto; }
  .side-brand .s { display: none; }
  .side-nav {
    flex-direction: row; overflow-x: auto; gap: 4px; flex: 1 1 0; min-width: 0;
    scrollbar-width: thin; padding-bottom: 2px;
  }
  .side-group, .side-foot { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 12px; flex: 0 0 auto; }
  .nav-item .ic { display: none; }
  .content { padding: 22px 18px 64px; min-width: 0; }
  .kv { grid-template-columns: 150px 1fr; }
}

@media (max-width: 767px) {
  :root { --fs-xl: 22px; --fs-2xl: 26px; }
  .topbar2 { padding: 0 14px; height: 56px; gap: 8px; }
  #page-title { display: none; } /* the section heading below already names the page */
  .topbar2 .who { min-width: 0; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  .content { padding: 16px 14px 88px; }
  .section-head h1 { font-size: var(--fs-lg); }
  .section-head .actions { margin-left: 0; width: 100%; }
  .s-card { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 10px; }
  .chart { height: 150px; gap: 5px; }
  .chart .bar-val { display: none; }
  .btn { width: auto; }
  .sticky-cta {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; padding: 12px 14px;
    background: #fff; border-top: 1px solid var(--line); box-shadow: var(--shadow-lg);
  }
  .sticky-cta .btn { width: 100%; }
  .toast { left: 14px; right: 14px; bottom: 76px; max-width: none; }
}

@media (min-width: 768px) { .sticky-cta { display: none; } }

@media print { .app-side, .topbar2, .sticky-cta, .toast { display: none !important; } }
