/* Gateway Mobile PWA — mobile.css */

:root {
    --brand: #4e73df;
    --brand-dark: #3a5cc7;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --header-h: 56px;
    --footer-h: 64px;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --text: #1a202c;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 4px rgba(0,0,0,.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--bg);
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
.m-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.m-header-side { width: 44px; display: flex; align-items: center; justify-content: center; }
.m-header-title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}
.m-icon-btn {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none; color: #fff;
    border-radius: 50%; cursor: pointer;
    font-size: 20px; text-decoration: none;
    transition: background .15s;
    flex-shrink: 0;
}
.m-icon-btn:hover, .m-icon-btn:active { background: rgba(255,255,255,.2); }

/* ── Content Areas ───────────────────────────────────────── */
.m-content {
    padding-top: var(--header-h);
    padding-bottom: var(--footer-h);
    min-height: 100vh;
}
.m-content-nofooter {
    padding-top: var(--header-h);
    min-height: 100vh;
}

/* ── Footer / Action Bar ─────────────────────────────────── */
.m-footer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--footer-h);
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 10px;
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
}
.m-footer-center {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────── */
.m-btn {
    min-height: 44px;
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    transition: opacity .15s, transform .1s;
    white-space: nowrap;
    font-family: inherit;
}
.m-btn:active { transform: scale(0.97); opacity: .9; }
.m-btn:disabled { opacity: .5; pointer-events: none; }
.m-btn-primary { background: var(--brand); color: #fff; }
.m-btn-success { background: var(--success); color: #fff; }
.m-btn-danger  { background: var(--danger);  color: #fff; }
.m-btn-outline { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.m-btn-ghost   { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.m-btn-full    { width: 100%; }
.m-btn-sm  { min-height: 36px; padding: 6px 14px; font-size: 13px; }
.m-btn-lg  { min-height: 52px; font-size: 17px; padding: 12px 24px; }
.m-btn-icon { width: 44px; height: 44px; padding: 0; border-radius: 50%; }

/* ── Cards ───────────────────────────────────────────────── */
.m-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin: 12px;
    box-shadow: var(--shadow);
}
.m-card-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .6px;
    margin-bottom: 14px;
}
.m-card + .m-card { margin-top: 0; }

/* ── Form Inputs ─────────────────────────────────────────── */
.m-field { margin-bottom: 16px; }
.m-field:last-child { margin-bottom: 0; }
.m-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: .5px;
}
.m-input, .m-select, .m-textarea {
    display: block;
    width: 100%;
    font-size: 16px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    appearance: none;
    -webkit-appearance: none;
    transition: border-color .15s;
    font-family: inherit;
}
.m-input:focus, .m-select:focus, .m-textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(78,115,223,.12);
}
.m-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}
.m-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.m-row { display: flex; gap: 10px; }
.m-row .m-field { flex: 1; margin-bottom: 0; }
.m-row + .m-field, .m-row + .m-row { margin-top: 16px; }

/* ── Section label ───────────────────────────────────────── */
.m-section {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-muted);
    padding: 16px 16px 6px;
}

/* ── List Items ──────────────────────────────────────────── */
.m-list { margin: 0 12px; }
.m-list-item {
    background: #fff;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: box-shadow .15s, transform .1s;
}
.m-list-item:active { transform: scale(.99); box-shadow: var(--shadow-md); }
.m-list-item-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.m-list-item-body { flex: 1; min-width: 0; }
.m-list-item-title { font-size: 15px; font-weight: 600; }
.m-list-item-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-list-item-right { text-align: right; flex-shrink: 0; }

/* ── Badges ──────────────────────────────────────────────── */
.m-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.m-badge-draft     { background: #fef3c7; color: #92400e; }
.m-badge-finalized { background: #d1fae5; color: #065f46; }
.m-badge-pending   { background: #dbeafe; color: #1e40af; }
.m-badge-revised   { background: #f3f4f6; color: #374151; }

/* ── Step progress dots ──────────────────────────────────── */
.m-step-dots { display: flex; gap: 6px; justify-content: center; align-items: center; }
.m-step-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--border);
    transition: all .2s;
}
.m-step-dot.active { background: var(--brand); width: 20px; border-radius: 3px; }
.m-step-dot.done   { background: var(--brand); opacity: .45; }

/* ── Running total bar ───────────────────────────────────── */
.m-total-bar {
    position: fixed;
    bottom: var(--footer-h);
    left: 0; right: 0;
    background: #1e293b;
    color: #fff;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 999;
    font-size: 14px;
}
.m-total-bar-label  { font-weight: 500; opacity: .75; }
.m-total-bar-amount { font-size: 20px; font-weight: 700; font-family: 'SF Mono', 'Fira Code', monospace; }

/* ── Toast ───────────────────────────────────────────────── */
#mToast {
    position: fixed;
    top: calc(var(--header-h) + 8px);
    left: 12px; right: 12px;
    background: #1e293b;
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    transform: translateY(-16px);
    opacity: 0;
    transition: transform .25s, opacity .25s;
    pointer-events: none;
    text-align: center;
}
#mToast.show     { transform: translateY(0); opacity: 1; }
#mToast.success  { background: var(--success); }
#mToast.error    { background: var(--danger); }
#mToast.warning  { background: var(--warning); }

/* ── Hamburger Menu ──────────────────────────────────────── */
.m-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}
.m-menu-overlay.open { opacity: 1; pointer-events: all; }
.m-menu-panel {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: min(280px, 80vw);
    background: #fff;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.33,1,.68,1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.m-menu-overlay.open .m-menu-panel { transform: translateX(0); }
.m-menu-header {
    background: var(--brand);
    color: #fff;
    padding: 20px 16px 16px;
    flex-shrink: 0;
}
.m-menu-user-name { font-size: 16px; font-weight: 700; }
.m-menu-user-role { font-size: 12px; opacity: .8; margin-top: 2px; text-transform: capitalize; }
.m-menu-items { flex: 1; padding: 8px 0; }
.m-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    text-decoration: none;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    transition: background .15s;
}
.m-menu-item:hover, .m-menu-item:active { background: #f5f7ff; }
.m-menu-item.active { color: var(--brand); background: #eff4ff; }
.m-menu-item-icon { font-size: 18px; width: 22px; text-align: center; opacity: .7; }
.m-menu-divider { height: 1px; background: var(--border); margin: 8px 0; }

/* ── Loading / Spinner ───────────────────────────────────── */
.m-spinner {
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}
.m-spinner-dark {
    border-color: rgba(0,0,0,.12);
    border-top-color: var(--brand);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Bottom Sheet ────────────────────────────────────────── */
.m-sheet-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1200;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}
.m-sheet-overlay.open { opacity: 1; pointer-events: all; }
.m-sheet {
    width: 100%;
    background: #fff;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32,0,.67,0);
    max-height: 92vh;
    overflow-y: auto;
}
.m-sheet-overlay.open .m-sheet { transform: translateY(0); transition-timing-function: cubic-bezier(.33,1,.68,1); }
.m-sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 10px auto 0; }
.m-sheet-title {
    font-size: 16px; font-weight: 700;
    padding: 14px 16px 0;
    display: flex; align-items: center; justify-content: space-between;
}
.m-sheet-body { padding: 16px; }

/* ── Accordion (rooms step) ──────────────────────────────── */
.m-accordion { margin: 12px; }
.m-accordion-item {
    background: #fff;
    border-radius: var(--radius);
    margin-bottom: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.m-accordion-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.m-accordion-header:active { background: #f8f9ff; }
.m-accordion-title  { flex: 1; font-weight: 600; font-size: 15px; }
.m-accordion-meta   { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.m-accordion-arrow  { font-size: 12px; color: var(--text-muted); transition: transform .2s; }
.m-accordion-item.open .m-accordion-arrow { transform: rotate(180deg); }
.m-accordion-body   { display: none; padding: 0 16px 16px; }
.m-accordion-item.open .m-accordion-body { display: block; }

/* ── Line items ──────────────────────────────────────────── */
.m-line-item {
    display: flex; align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}
.m-line-item:last-of-type { border-bottom: none; }
.m-line-item-name  { flex: 1; font-size: 13px; min-width: 0; line-height: 1.3; }
.m-line-item-qty   { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.m-line-item-total { font-size: 13px; font-weight: 600; font-family: monospace; white-space: nowrap; min-width: 70px; text-align: right; }
.m-line-item-del   { color: var(--danger); background: none; border: none; font-size: 18px; padding: 4px; cursor: pointer; flex-shrink: 0; opacity: .7; }
.m-line-item-del:active { opacity: 1; }

/* ── Cost summary rows ───────────────────────────────────── */
.m-cost-row {
    display: flex; align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.m-cost-row:last-child { border-bottom: none; }
.m-cost-label { flex: 1; font-size: 14px; }
.m-cost-value { font-size: 14px; font-family: monospace; font-weight: 600; min-width: 100px; text-align: right; }
.m-cost-row.subtotal { opacity: .6; }
.m-cost-row.total-row { border-top: 2px solid var(--text); padding-top: 14px; margin-top: 4px; }
.m-cost-row.total-row .m-cost-label { font-weight: 700; font-size: 15px; }
.m-cost-row.total-row .m-cost-value { font-size: 18px; font-weight: 800; }
.m-cost-row.unmet .m-cost-value { color: var(--danger); }
.m-cost-row.unmet.zero .m-cost-value { color: var(--success); }

/* ── Search bar ──────────────────────────────────────────── */
.m-search-wrap {
    padding: 10px 12px;
    position: sticky;
    top: var(--header-h);
    background: var(--bg);
    z-index: 10;
}
.m-search-inner { position: relative; }
.m-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; font-size: 16px; }
.m-search-input {
    width: 100%; padding: 12px 14px 12px 44px;
    font-size: 16px; border-radius: 50px;
    border: 1.5px solid var(--border); background: #fff;
    appearance: none; -webkit-appearance: none;
}
.m-search-input:focus { outline: none; border-color: var(--brand); }

/* ── Empty state ─────────────────────────────────────────── */
.m-empty { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.m-empty-icon  { font-size: 52px; margin-bottom: 12px; opacity: .35; }
.m-empty-title { font-size: 17px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.m-empty-sub   { font-size: 14px; line-height: 1.5; }

/* ── Info grid (property display) ────────────────────────── */
.m-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-info-item label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); display: block; margin-bottom: 3px; }
.m-info-item span  { font-size: 14px; font-weight: 500; }

/* ── Login page ──────────────────────────────────────────── */
.m-login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 24px 20px;
    background: var(--bg);
}
.m-login-logo { text-align: center; margin-bottom: 32px; }
.m-login-logo-mark { width: 64px; height: 64px; background: var(--brand); border-radius: 16px; display: inline-flex; align-items: center; justify-content: center; font-size: 32px; color: #fff; margin-bottom: 12px; }
.m-login-title { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.m-login-sub   { font-size: 14px; color: var(--text-muted); text-align: center; }
.m-login-card  { background: #fff; border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-md); }
.m-alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.m-alert-error   { background: #fee2e2; color: #991b1b; }
.m-alert-success { background: #d1fae5; color: #065f46; }

/* ── Module tiles (home) ─────────────────────────────────── */
.m-modules { padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-module-tile {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    box-shadow: var(--shadow);
    text-decoration: none; color: var(--text);
    transition: transform .1s, box-shadow .15s;
}
.m-module-tile:active { transform: scale(.97); box-shadow: var(--shadow-md); }
.m-module-tile.disabled { opacity: .45; pointer-events: none; }
.m-module-tile-icon { font-size: 32px; margin-bottom: 8px; }
.m-module-tile-name { font-size: 13px; font-weight: 700; }
.m-module-tile-sub  { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── Catalog picker ──────────────────────────────────────── */
.m-catalog-overlay {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 1300;
    display: flex; flex-direction: column;
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32,0,.67,0);
}
.m-catalog-overlay.open { transform: translateY(0); transition-timing-function: cubic-bezier(.33,1,.68,1); }
.m-catalog-header {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
    padding-top: env(safe-area-inset-top, 0);
    min-height: 56px;
}
.m-catalog-header-title { flex: 1; font-weight: 700; font-size: 16px; }
.m-catalog-tabs {
    display: flex; gap: 0;
    overflow-x: auto;
    border-bottom: 2px solid var(--border);
    background: #fff;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.m-catalog-tabs::-webkit-scrollbar { display: none; }
.m-catalog-tab {
    padding: 10px 14px;
    font-size: 12px; font-weight: 600;
    white-space: nowrap; cursor: pointer;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s;
}
.m-catalog-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.m-catalog-items { flex: 1; overflow-y: auto; }
.m-catalog-item {
    display: flex; align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    cursor: pointer;
    transition: background .1s;
}
.m-catalog-item:active { background: #f5f7ff; }
.m-catalog-item.selected { background: #eff4ff; }
.m-catalog-check {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 12px; color: transparent;
    transition: all .15s;
}
.m-catalog-item.selected .m-catalog-check { border-color: var(--brand); background: var(--brand); color: #fff; }
.m-catalog-item-name  { flex: 1; font-size: 14px; }
.m-catalog-item-price { font-size: 13px; font-family: monospace; color: var(--text-muted); white-space: nowrap; }
.m-catalog-footer {
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 12px;
    flex-shrink: 0;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
}

/* ── iOS safe area ───────────────────────────────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
    .m-footer {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(var(--footer-h) + env(safe-area-inset-bottom));
    }
    .m-content { padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom)); }
    .m-total-bar { bottom: calc(var(--footer-h) + env(safe-area-inset-bottom)); }
    body { padding-bottom: 0; }
}

/* ── Utilities ───────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.fw-bold      { font-weight: 700; }
.font-mono    { font-family: monospace; }
.d-none       { display: none !important; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-12 { margin-bottom: 12px; }
.mb-0  { margin-bottom: 0 !important; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
