:root {
  --navy: #071d49;
  --blue: #1e6cff;
  --orange: #ff7a00;
  --green: #16a66a;
  --purple: #7256e8;
  --red: #ef233c;
  --text: #111827;
  --muted: #687386;
  --line: #e7ebf2;
  --bg: #f6f8fc;
  --card: #fff;
  --shadow: 0 8px 24px rgba(7,29,73,.08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); font-family: Arial, sans-serif; color: var(--text); height: 100%; overflow: hidden; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

/* ---- APP SHELL ---- */
.app-shell { max-width: 430px; margin: 0 auto; height: 100vh; background: #fff; position: relative; display: flex; flex-direction: column; }
main#app { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---- TOPBAR ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; min-height: 72px;
  padding: env(safe-area-inset-top) 16px 0;
  display: grid; grid-template-columns: 44px 1fr 44px; align-items: center;
  background: linear-gradient(135deg, var(--navy), #001233);
  color: #fff; flex-shrink: 0;
}
.icon-btn { border: 0; background: transparent; color: #fff; font-size: 24px; }
.brand { text-align: center; line-height: 1.05; }
.brand strong { display: block; font-size: 23px; }
.brand span { display: block; color: var(--orange); font-weight: 800; font-size: 11px; margin-top: 4px; }

/* ---- PAGES ---- */
.page { padding: 18px 16px 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; margin-bottom: 5px; }
h2 { font-size: 18px; margin-bottom: 12px; }
.subtle { color: var(--muted); font-size: 13px; }

/* ---- GRID ---- */
.grid { display: grid; gap: 10px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

/* ---- CARDS ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.metric { min-height: 110px; }
.metric .label { font-size: 11px; font-weight: 800; text-transform: uppercase; }
.metric .value { font-size: 30px; font-weight: 800; margin: 12px 0 6px; }
.metric .money { font-size: 12px; color: #32415f; }
.blue { color: var(--blue); }
.orange { color: var(--orange); }
.green { color: var(--green); }
.purple { color: var(--purple); }
.red { color: var(--red); }

/* ---- SECTION HEAD ---- */
.section-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 10px; }
.link-btn { border: 0; background: transparent; color: var(--blue); font-weight: 700; font-size: 13px; }

/* ---- ORDER ROW ---- */
.order-row, .product-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.order-row:last-child, .product-row:last-child { border-bottom: 0; }
.order-main strong { display: block; margin-bottom: 5px; }
.meta { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge.open { background: #e7f0ff; color: var(--blue); }
.badge.partial { background: #fff0df; color: var(--orange); }
.badge.complete { background: #e7f8ef; color: var(--green); }
.badge.overdue { background: #ffe7e7; color: #cc0000; }
.order-row.overdue { border-left: 3px solid #cc0000; background: #fff5f5; margin-bottom: 4px; border-radius: 4px; padding-left: 10px; }
.badge.ready { background: #efeafd; color: var(--purple); }
.badge.outstanding { background: #ffe5e5; color: var(--red); }

/* ---- BUTTONS ---- */
.primary-btn, .secondary-btn, .danger-btn { width: 100%; border-radius: 10px; padding: 14px 16px; font-weight: 800; border: none; }
.primary-btn { background: var(--navy); color: #fff; }
.secondary-btn { background: #fff; border: 1px solid var(--blue); color: var(--blue); }
.danger-btn { background: var(--red); color: #fff; }
.primary-btn:disabled { background: #94a3b8; cursor: not-allowed; }

/* ---- QUICK ACTIONS ---- */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.quick-action { border: 1px solid var(--line); background: #fff; border-radius: 14px; padding: 12px 6px; text-align: center; }
.quick-action span { display: block; font-size: 22px; margin-bottom: 6px; }
.quick-action small { font-size: 10px; font-weight: 700; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 0 -16px 14px; padding: 0 16px; }
.tab { white-space: nowrap; border: 0; background: transparent; padding: 12px 10px; color: #4a5873; font-size: 12px; font-weight: 700; }
.tab.active { color: var(--blue); border-bottom: 3px solid var(--blue); }

/* ---- LIST CARDS ---- */
.list-card { padding: 0 14px; margin-bottom: 12px; border-left: 4px solid var(--blue); }
.list-card.partial { border-left-color: var(--orange); }
.list-card.complete { border-left-color: var(--green); }
.list-card.ready { border-left-color: var(--purple); }
.list-card.outstanding { border-left-color: var(--red); }
.order-card-content { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 14px 0; }
.order-card-content h3 { margin-bottom: 6px; }
.order-card-content .amount { text-align: right; font-weight: 800; line-height: 1.6; }

/* ---- DETAIL ---- */
.detail-title { display: flex; gap: 10px; align-items: center; margin-bottom: 4px; flex-wrap: wrap; }
.summary-grid .card { text-align: center; padding: 12px 8px; }
.summary-grid .label { font-size: 10px; color: var(--muted); }
.summary-grid .value { font-size: 17px; font-weight: 800; margin-top: 6px; }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { background: #f1f4f9; text-align: left; color: #52617b; }
th, td { padding: 10px 7px; border-bottom: 1px solid var(--line); vertical-align: top; }

/* ---- ACTIONS ---- */
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }

/* ---- PRODUCTS ---- */
.product-thumb { width: 48px; height: 48px; border-radius: 12px; background: #f4eadc; display: grid; place-items: center; font-size: 25px; flex-shrink: 0; }
.product-row { grid-template-columns: 52px 1fr auto; align-items: center; }
.stock { text-align: right; color: var(--green); font-size: 11px; font-weight: 800; }

/* ---- REPORTS ---- */
.kpi-card .value { font-size: 19px; font-weight: 800; margin: 8px 0; }
.kpi-card .trend { font-size: 11px; color: var(--green); }
.chart { height: 210px; border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: linear-gradient(#fff, #fbfcff); }
.donut { width: 130px; height: 130px; border-radius: 50%; background: conic-gradient(var(--green) 0 60%, var(--orange) 60% 82%, var(--blue) 82% 100%); position: relative; margin: 14px auto; }
.donut::after { content: ""; position: absolute; inset: 30px; background: #fff; border-radius: 50%; }
.legend { display: grid; gap: 8px; font-size: 12px; }
.legend div { display: flex; justify-content: space-between; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 12px; font-weight: 800; margin-bottom: 8px; }
input, select, textarea { width: 100%; border: 1px solid #dbe2ee; border-radius: 10px; padding: 13px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--navy); }
textarea { min-height: 110px; resize: vertical; }
.upload { border: 1px dashed #b9c5d8; border-radius: 12px; height: 140px; display: grid; place-items: center; color: #52617b; text-align: center; cursor: pointer; }

/* ---- BOTTOM NAV ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(430px, 100%); height: 72px; background: #fff;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr);
  z-index: 30; padding-bottom: env(safe-area-inset-bottom);
}
.nav-item { border: 0; background: transparent; color: #53627d; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.nav-item span { font-size: 20px; }
.nav-item small { font-size: 10px; font-weight: 700; }
.nav-item.active { color: var(--orange); }

/* ---- LOGIN ---- */
.login-overlay { position: fixed; inset: 0; background: linear-gradient(135deg, var(--navy), #001233); display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-box { background: #fff; border-radius: 24px; padding: 40px 30px; width: 90%; max-width: 340px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-box img { width: 80px; height: 80px; border-radius: 18px; margin-bottom: 16px; object-fit: contain; }
.login-box h1 { font-size: 22px; color: var(--navy); margin-bottom: 4px; }
.login-box .subtitle { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.login-box label { text-align: left; font-size: 12px; font-weight: 800; color: #4a5873; }
.login-box input { text-align: center; letter-spacing: 8px; font-size: 18px; margin-bottom: 16px; }
.login-box .error { color: var(--red); font-size: 13px; margin-top: 8px; min-height: 20px; }

/* ---- EMPTY ---- */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---- TOAST ---- */
.toast { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 22px; border-radius: 20px; font-size: 13px; font-weight: 600; z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.toast.show { opacity: 1; }

/* ---- OFFLINE ---- */
.offline-banner { background: var(--orange); color: #fff; text-align: center; padding: 8px; font-size: 12px; font-weight: 600; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }
