/* Ware House MS — app shell: mobile app-like, desktop-ready */
:root {
    /* Brand: logistics blue */
    --brand: #1558a0;
    --brand-dark: #0f4278;
    --brand-tint: #e8f0f9;
    --brand-on: #dce9f7;
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #161b22;
    --muted: #67717d;
    --border: #e1e6ec;
    --danger: #c0392b;
    /* Status colours stay semantic, independent of brand */
    --ok: #1f7a4d;
    --ok-bg: #e7f6ee;
    --radius: 14px;
    --shadow: 0 2px 12px rgba(0, 0, 0, .06);
    --appbar-h: 56px;
    --bottomnav-h: 62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

/* ---------------- App bar ---------------- */
.app-bar {
    position: sticky; top: 0; z-index: 40;
    height: var(--appbar-h);
    background: var(--brand);
    color: #fff;
    box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top);
}
.app-bar__inner {
    height: var(--appbar-h);
    max-width: 1100px; margin: 0 auto;
    display: flex; align-items: center; gap: 12px;
    padding: 0 16px;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; }
.brand__mark { font-size: 20px; }
.brand__text { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }
.topnav { display: none; margin-left: auto; gap: 4px; }
.topnav a {
    color: var(--brand-on); text-decoration: none; font-size: 14px; font-weight: 500;
    padding: 8px 12px; border-radius: 8px;
}
.topnav a:hover { background: rgba(255, 255, 255, .15); }
.logout { margin-left: auto; }
.logout button {
    background: rgba(255, 255, 255, .16); color: #fff; border: 0;
    width: 38px; height: 38px; border-radius: 10px; font-size: 18px; cursor: pointer;
}
.topnav + .logout { margin-left: 4px; }

/* ---------------- Content ---------------- */
.content {
    max-width: 1100px; margin: 0 auto;
    padding: 16px 16px calc(var(--bottomnav-h) + 24px);
}
.page-head { margin: 6px 0 16px; }
.page-head h1 { font-size: 22px; margin: 0; }
.page-head--row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); margin: 2px 0 0; }
.section-title { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 24px 0 10px; }

/* ---------------- Stat grid ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat__num { font-size: 28px; font-weight: 800; color: var(--brand-dark); }
.stat__label { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------------- Tiles ---------------- */
.tile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 16px; text-decoration: none; color: var(--ink); font-weight: 600;
    display: flex; flex-direction: column; gap: 10px;
}
.tile:active { transform: scale(.98); }
.tile__icon { font-size: 26px; }

/* ---------------- Cards ---------------- */
.card-list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.card__title { font-weight: 700; }
.card__meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 0; border-radius: 10px; padding: 10px 16px; font-size: 15px; font-weight: 600;
    text-decoration: none; cursor: pointer; min-height: 44px;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:active { background: var(--brand-dark); }
.btn--ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--block { width: 100%; }

/* ---------------- Tables → cards on mobile ---------------- */
.data-table-wrap { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { display: none; }
.data-table tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.data-table tr:last-child { border-bottom: 0; }
.data-table td { display: flex; justify-content: space-between; gap: 16px; padding: 4px 0; font-size: 15px; }
.data-table td::before {
    content: attr(data-label); color: var(--muted); font-size: 13px; font-weight: 600;
}
.data-table td.col-actions { justify-content: flex-end; gap: 18px; padding-top: 10px; }
.data-table td.col-actions::before { content: ""; }
.link-edit { color: var(--brand-dark); text-decoration: none; font-weight: 600; }
.link-delete { color: var(--danger); text-decoration: none; font-weight: 600; }

/* ---------------- Forms ---------------- */
.form-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 16px; max-width: 560px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea,
.form-card input, .form-card select, .form-card textarea {
    width: 100%; padding: 12px 14px; font-size: 16px;
    border: 1px solid var(--border); border-radius: 10px; background: #fff; color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.help { color: var(--muted); font-size: 12px; }
.field-error { color: var(--danger); font-size: 13px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---------------- Messages / empty / pager ---------------- */
.messages { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert--error { background: #fdecea; color: var(--danger); }
.alert--warning { background: #fff6e0; color: #8a6d00; }
.alert--success { background: var(--ok-bg); color: var(--ok); }
.alert--info { background: var(--brand-tint); color: var(--brand-dark); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty__icon { font-size: 42px; margin-bottom: 8px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; color: var(--muted); }
.pager a { color: var(--brand-dark); text-decoration: none; font-weight: 600; }

/* ---------------- Bottom nav (mobile) ---------------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    height: var(--bottomnav-h);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex; align-items: stretch;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600;
}
.bottom-nav a span { font-size: 20px; }
.bottom-nav a:active { color: var(--brand); }

/* ---------------- Workflow components ---------------- */
.card--link { display: block; text-decoration: none; color: var(--ink); }
.card--link:active { transform: scale(.99); }
.card__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pill { background: var(--brand-tint); color: var(--brand-dark); font-size: 13px; font-weight: 700;
        padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: #fff6e0; color: #8a6d00; }
.badge--void { background: #fdecea; color: #c0392b; }
.line-metrics { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 10px 0; color: var(--muted); font-size: 14px; }
.line-metrics b { color: var(--ink); }
.line-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: #fafbfd; }
.line-remove { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 4px; }
.line-remove input { width: auto; }
.stat-grid--3 { grid-template-columns: repeat(3, 1fr); }

/* radio pills (source toggle) */
.radio-row { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.radio-pill { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border);
    border-radius: 10px; padding: 12px 14px; flex: 1; min-width: 140px; font-size: 14px; font-weight: 600; }
.radio-pill input { width: auto; }

/* detail rows */
.detail-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px; }
.detail-row { display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 12px 16px; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: 0; }
.detail-row > span { color: var(--muted); font-size: 14px; }

/* ---------------- Login ---------------- */
.login-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%); padding: 20px;
}
.login-card {
    background: #fff; border-radius: 20px; box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
    padding: 32px 24px; width: 100%; max-width: 380px; text-align: center;
}
.login-logo { font-size: 46px; }
.login-title { margin: 8px 0 2px; font-size: 22px; }
.login-sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-card .field { text-align: left; }

/* ---------------- Desktop ---------------- */
@media (min-width: 768px) {
    .topnav { display: flex; }
    .app-bar__inner .logout { margin-left: 4px; }
    .bottom-nav { display: none; }
    .content { padding-bottom: 32px; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
    .tile-grid { grid-template-columns: repeat(5, 1fr); }

    /* Real table on desktop */
    .data-table thead { display: table-header-group; }
    .data-table { border-collapse: collapse; }
    .data-table tr { display: table-row; padding: 0; border-bottom: 0; }
    .data-table th, .data-table td { display: table-cell; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
    .data-table td { justify-content: initial; }
    .data-table td::before { content: ""; }
    .data-table thead th { background: #eef2f7; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
    .data-table td.col-actions { text-align: right; }
}

/* ---------------- Search / filter bar ---------------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.filter-bar input[type="search"],
.filter-bar select {
    flex: 1 1 160px; min-height: 44px; padding: 8px 12px;
    border: 1px solid var(--border, #cdd6d1); border-radius: 10px;
    font-size: 15px; background: #fff;
}
.filter-bar .btn { flex: 0 0 auto; }

/* Bottom nav carries 5 slots — keep labels on one line down to 320px screens. */
.bottom-nav a { min-width: 0; padding: 0 2px; }
.bottom-nav a span { line-height: 1; }
@media (max-width: 360px) {
    .bottom-nav a { font-size: 10px; }
    .bottom-nav a span { font-size: 18px; }
}
