:root {
    --primary: #e31e24;
    --primary-dark: #730101;
    --accent: #ec8a8d;
    --text: #434242;
    --muted: #7b7474;
    --surface: #fefefe;
    --bg: #f7f4f4;
    --border: #eadfdf;
    --success: #177245;
    --warning: #a16207;
    --danger: #b42318;
    --shadow: 0 16px 36px rgba(67, 66, 66, 0.08);
    --radius: 18px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Manrope', sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(227, 30, 36, 0.08), transparent 24rem),
        radial-gradient(circle at top right, rgba(236, 138, 141, 0.16), transparent 22rem),
        var(--bg);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.app-shell { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.sidebar {
    background: linear-gradient(180deg, rgba(254, 254, 254, 0.98), rgba(254, 254, 254, 0.92));
    border-right: 1px solid var(--border);
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    padding: 0 4px 6px;
    background: transparent;
    border: none;
    box-shadow: none;
}
.brand-logo {
    width: 150px;
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.nav { display: grid; gap: 6px; margin-top: 18px; }
.nav-link {
    padding: 10px 10px;
    border-radius: 14px;
    color: var(--text);
    border: 1px solid transparent;
    font-size: 13px;
}
.nav-link:hover, .nav-link.is-active {
    background: var(--surface);
    border-color: var(--border);
    box-shadow: var(--shadow);
}
.nav-link.is-active { color: var(--primary); font-weight: 700; }
.nav-link.is-danger { color: var(--danger); }

.main { padding: 18px; }
.topbar { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 16px; }
.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .16em;
    color: var(--primary);
    font-weight: 800;
}
h1 { margin: 0; font-size: 28px; line-height: 1.08; }
.subtitle { margin: 8px 0 0; color: var(--muted); }
.user-pill {
    background: rgba(254, 254, 254, .88);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 12px;
    display: inline-flex;
    align-items: center;
    box-shadow: var(--shadow);
}
.user-pill span { color: var(--muted); font-size: 13px; font-weight: 700; }

.grid { display: grid; gap: 20px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.card {
    background: rgba(254, 254, 254, .94);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(234, 223, 223, .95);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}
.hero-card { display: grid; grid-template-columns: 1.25fr .75fr; gap: 20px; overflow: hidden; }
.hero-panel {
    background: linear-gradient(135deg, #730101, #a90d12 58%, #e31e24);
    color: white;
    padding: 24px;
    border-radius: 18px;
}
.hero-panel p { color: rgba(255,255,255,.82); }
.stats strong { display: block; font-size: 26px; }
.stats span { color: var(--muted); font-size: 13px; }

.btn, .btn-secondary, .btn-ghost, .btn-danger {
    border: none;
    border-radius: 12px;
    padding: 9px 12px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: .2s ease;
}
.btn { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; }
.btn:hover { transform: translateY(-1px); }
.btn-secondary { background: var(--text); color: var(--surface); }
.btn-ghost { background: rgba(236, 138, 141, 0.18); color: var(--primary-dark); }
.btn-danger { background: rgba(227, 30, 36, 0.1); color: var(--primary-dark); }

.field-grid { display: grid; gap: 12px; grid-template-columns: repeat(12, 1fr); }
.field { display: grid; gap: 8px; }
.field.col-12 { grid-column: span 12; }
.field.col-6 { grid-column: span 6; }
.field.col-4 { grid-column: span 4; }
.field label { font-size: 12px; font-weight: 700; color: var(--text); }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: white;
    padding: 9px 11px;
    color: var(--text);
    font-size: 13px;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: rgba(227, 30, 36, 0.45);
    box-shadow: 0 0 0 4px rgba(227, 30, 36, 0.08);
}
.field textarea { min-height: 68px; resize: vertical; }

.order-block {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 14px;
    background: linear-gradient(180deg, #fff, #fcf6f6);
}
.order-block + .order-block { margin-top: 18px; }
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }

.address-stack { display: grid; gap: 10px; position: relative; z-index: 3; }
.address-card {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    background: rgba(255,255,255,.92);
    position: relative;
    z-index: 3;
    cursor: pointer;
}
.address-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

.map-modal {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 1000;
}
.map-modal.is-open { display: flex; }
.map-modal-card {
    width: min(1100px, 100%);
    background: white;
    border-radius: 20px;
    padding: 14px;
    box-shadow: var(--shadow);
}
.map-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
.map-panel { display: grid; gap: 12px; position: relative; z-index: 3; }
#locationMap { width: 100%; min-height: 560px; border-radius: 16px; overflow: hidden; position: relative; z-index: 1; }

.hint { font-size: 12px; color: var(--muted); }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.badge { display: inline-flex; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.placed { background: #fce8e8; color: var(--primary-dark); }
.badge.accepted { background: #f8d8d9; color: #9e1015; }
.badge.dispatched, .badge.reached_pickup, .badge.reached_drop { background: #fde6e7; color: #8f272a; }
.badge.delivered { background: #dcfce7; color: #166534; }
.badge.cancelled { background: #fee2e2; color: #b91c1c; }

.empty { color: var(--muted); padding: 24px 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.timeline { display: grid; gap: 12px; }
.timeline-item { position: relative; padding: 14px 16px 14px 22px; border: 1px solid var(--border); border-radius: 16px; }
.timeline-item::before { content: ''; position: absolute; left: 10px; top: 20px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: 1.02fr .98fr; }
.login-visual {
    padding: 22px 24px 16px;
    color: white;
    background: linear-gradient(145deg, #730101, #a70d13 55%, #e31e24 115%);
    display: grid;
    align-content: space-between;
}
.login-visual-copy {
    display: grid;
    align-content: start;
    gap: 16px;
}
.login-panel { display: grid; place-items: center; padding: 20px; }
.login-card { width: min(392px, 100%); }
.login-logo {
    width: 138px;
    max-width: 100%;
    margin: 0;
    object-fit: contain;
    filter: brightness(0) invert(1);
}
.login-visual h1 {
    max-width: 360px;
    font-size: 36px;
    line-height: 1.04;
    margin: 0;
}
.login-visual-note {
    align-self: end;
    padding: 14px 18px;
    border-radius: 20px;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.18);
    color: white;
    width: min(100%, 420px);
}
.login-visual-note strong {
    display: block;
    font-size: 16px;
    line-height: 1.2;
}
.login-card h1 { font-size: 28px !important; }
.login-card .subtitle { margin-top: 6px; font-size: 14px; }
.login-card .field-grid { margin-top: 16px !important; gap: 12px; }
.login-card .actions { margin-top: 12px; }
.login-card .btn,
.login-card .btn-secondary {
    min-width: 0;
    padding: 10px 14px;
}

.panel-note { padding: 14px 16px; border-radius: 16px; background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.success { color: var(--success); }
.danger { color: var(--danger); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.open-map-btn {
    padding: 7px 10px;
    font-size: 12px;
    border-radius: 10px;
}

.order-block .btn-danger.remove-order-btn {
    padding: 8px 10px;
    font-size: 12px;
}

@media (max-width: 1100px) {
    .grid.cols-4, .grid.cols-3, .grid.cols-2, .hero-card, .split, .map-layout, .login-shell, .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .login-visual h1 { font-size: 32px; }
}

@media (max-width: 720px) {
    .main { padding: 16px; }
    .topbar { flex-direction: column; }
    .field.col-6, .field.col-4 { grid-column: span 12; }
    #locationMap { min-height: 360px; }
    .login-visual { padding: 20px 18px 14px; gap: 18px; }
    .login-logo { width: 118px; }
    .login-visual h1 { font-size: 28px; max-width: 280px; }
    .login-visual-note { padding: 12px 14px; border-radius: 18px; }
    .login-card { width: 100%; }
}
