:root {
    --navy: #0b1220;
    --navy-2: #141d2f;
    --navy-3: #1c2740;
    --canvas: #f5f6f8;
    --card: #ffffff;
    --border: #e6e8ec;
    --border-soft: #eef0f3;
    --ink: #0f172a;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --accent: #ea6a1f;
    --accent-dark: #c95412;
    --accent-soft: #fff1e6;
    --teal: #0f9d8f;
    --teal-soft: #e7f8f6;
    --red: #dc2626;
    --red-soft: #fdecec;
    --sidebar-w: 264px;
    --sidebar-w-collapsed: 76px;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.10);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--canvas);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.mono {
    font-family: 'IBM Plex Mono', monospace;
}

/* ---------- LAYOUT ---------- */
.app {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    transition: width .22s ease, transform .25s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    z-index: 40;
}

.sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
}

/* Mobile overlay backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 35;
    opacity: 0;
    transition: opacity .25s ease;
    pointer-events: none;
}

.sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    white-space: nowrap;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), #ffb069);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #1a0d02;
    font-size: 16px;
}

.brand-text {
    overflow: hidden;
}

.brand-text .name {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    line-height: 1.2;
}

.brand-text .sub {
    font-size: 11.5px;
    color: var(--muted-2);
    letter-spacing: .04em;
}

.sidebar.collapsed .brand-text {
    display: none;
}

.nav {
    flex: 1;
    padding: 14px 12px;
    overflow-y: auto;
}

.nav-group-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #54607a;
    padding: 14px 12px 6px;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar.collapsed .nav-group-label {
    display: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 9px;
    cursor: pointer;
    color: #aab3c5;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: background .15s, color .15s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.nav-item.active {
    background: var(--navy-3);
    color: #fff;
    border-color: rgba(234, 106, 31, 0.35);
}

.nav-item.active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item .label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .nav-item .label {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
}

.sidebar.collapsed .nav-item.active::before {
    left: 0;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--navy-3);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-footer .who {
    overflow: hidden;
}

.sidebar-footer .who .n {
    font-size: 13px;
    color: #fff;
    font-weight: 600;
}

.sidebar-footer .who .r {
    font-size: 11px;
    color: var(--muted-2);
}

.sidebar.collapsed .sidebar-footer .who {
    display: none;
}

/* ---------- MAIN ---------- */
.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(245, 246, 248, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--card);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    transition: background .15s;
    flex-shrink: 0;
}

.toggle-btn:hover {
    background: #f1f2f5;
}

.topbar-title {
    font-size: 18px;
    font-weight: 700;
}

.topbar-crumb {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 2px;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pill {
    font-size: 12px;
    font-weight: 600;
    padding: 6px 11px;
    border-radius: 20px;
    background: var(--teal-soft);
    color: var(--teal);
    display: flex;
    align-items: center;
    gap: 6px;
}

.pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--teal);
}

.content {
    padding: 20px 16px;
    max-width: 1180px;
    width: 100%;
    margin: 0 auto;
}

.tab-panel {
    display: none;
    animation: fade .25s ease;
}

.tab-panel.active {
    display: block;
}

@keyframes fade {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-head {
    margin-bottom: 22px;
}

.page-head h1 {
    font-size: 22px;
    margin: 0 0 4px;
    font-weight: 800;
    letter-spacing: -.01em;
}

.page-head p {
    margin: 0;
    color: var(--muted);
    font-size: 14px;
}

/* ---------- CARDS ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-head {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-head h2 {
    font-size: 15px;
    margin: 0;
    font-weight: 700;
}

.card-head p {
    font-size: 12.5px;
    color: var(--muted);
    margin: 3px 0 0;
}

.card-body {
    padding: 20px 22px;
}

.card+.card {
    margin-top: 18px;
}

.grid {
    display: grid;
    gap: 18px;
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

@media(max-width:980px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ---------- STAT CARD ---------- */
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.stat-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-label {
    font-size: 12.5px;
    color: var(--muted);
    font-weight: 600;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.02em;
}

.stat-delta {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
}

.stat-delta.up {
    color: var(--teal);
}

.stat-delta.down {
    color: var(--red);
}

/* ---------- FORM ELEMENTS ---------- */
label.field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink);
}

.field-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
}

input[type=text],
input[type=number],
input[type=search],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--ink);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.input-prefix {
    display: flex;
    align-items: stretch;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.input-prefix span {
    background: #f8f9fb;
    color: var(--muted);
    font-size: 12.5px;
    padding: 9px 10px;
    border-right: 1px solid var(--border);
    white-space: nowrap;
    font-family: 'IBM Plex Mono', monospace;
    display: flex;
    align-items: center;
}

.input-prefix input {
    border: none;
    border-radius: 0;
    box-shadow: none !important;
}

.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-soft);
    gap: 20px;
}

.field-row:last-child {
    border-bottom: none;
}

.field-row .field-text .t {
    font-size: 13.5px;
    font-weight: 600;
}

.field-row .field-text .d {
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}

.switch {
    position: relative;
    width: 42px;
    height: 24px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    inset: 0;
    background: #dfe3e9;
    border-radius: 20px;
    cursor: pointer;
    transition: .2s;
}

.slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.switch input:checked+.slider {
    background: var(--accent);
}

.switch input:checked+.slider::before {
    transform: translateX(18px);
}

/* buttons */
.btn {
    appearance: none;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    padding: 9px 15px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: background .15s, border-color .15s;
}

.btn:hover {
    background: #f4f5f7;
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.btn-ghost {
    border-color: transparent;
    background: transparent;
}

.btn-ghost:hover {
    background: #f1f2f5;
}

.btn-danger {
    color: var(--red);
    border-color: var(--red-soft);
    background: var(--red-soft);
}

.btn-danger:hover {
    background: #fbdada;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 12.5px;
}

.btn svg {
    width: 15px;
    height: 15px;
}

.actions-bar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Search + dropdown (produk) */
.combo {
    position: relative;
}

.combo-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-height: 230px;
    overflow-y: auto;
    z-index: 30;
    display: none;
}

.combo-list.open {
    display: block;
}

.combo-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13.5px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.combo-item:hover {
    background: var(--accent-soft);
}

.combo-item .nm {
    font-weight: 600;
}

.combo-item .cat {
    color: var(--muted);
    font-size: 12px;
}

.combo-empty {
    padding: 14px;
    font-size: 13px;
    color: var(--muted);
    text-align: center;
}

.chip-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.chip {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--accent-soft);
    color: var(--accent-dark);
    border: 1px solid #ffdcb8;
    padding: 6px 8px 6px 12px;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
}

.chip button {
    border: none;
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    line-height: 1;
}

/* Ongkir table */
.ongkir-section+.ongkir-section {
    margin-top: 18px;
}

.row-table {
    width: 100%;
    border-collapse: collapse;
}

.row-table th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    padding: 0 10px 8px;
    font-weight: 700;
}

.row-table td {
    padding: 6px 10px;
    vertical-align: middle;
}

.row-table tr.entry-row td {
    padding-top: 5px;
    padding-bottom: 5px;
}

/* Pengiriman */
#areaListWrap {
    margin-top: 22px;
}

.area-card {
    border: 1.5px solid #cdd3dd;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.area-card-head {
    padding: 14px 18px;
    background: #f7f8fa;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1.5px solid #e2e6ed;
}

.area-card-head .nm {
    font-weight: 700;
    font-size: 15px;
}

.area-card-head .days {
    font-size: 12.5px;
    color: var(--muted);
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.day-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    height: auto;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: #eef0f3;
    color: var(--muted-2);
    white-space: nowrap;
}

.day-badge.on {
    background: var(--teal-soft);
    color: var(--teal);
    border: 1px solid #b8e8e2;
}

.area-card-body {
    padding: 16px 18px;
}

.loc-row {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr .8fr auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.loc-row-head {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr .8fr auto;
    gap: 10px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 700;
    margin-bottom: 8px;
}

@media(max-width:900px) {

    .loc-row,
    .loc-row-head {
        grid-template-columns: 1fr;
    }
}

.day-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.day-toggle {
    width: 38px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
}

.day-toggle.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.json-preview {
    background: var(--navy);
    color: #d7e2f2;
    border-radius: 10px;
    padding: 16px 18px;
    font-size: 12.5px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
    max-height: 340px;
    overflow-y: auto;
    border: 1px dashed rgba(255, 255, 255, 0.15);
}

.json-preview .k {
    color: #7fd8ff;
}

.json-preview .s {
    color: #ffce7f;
}

.json-preview .n {
    color: #a3ffb0;
}

/* Log activity */
.log-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    align-items: center;
}

.log-toolbar input {
    max-width: 280px;
}

table.log-table {
    width: 100%;
    border-collapse: collapse;
}

table.log-table th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    background: #fafbfc;
}

table.log-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 13px;
    vertical-align: top;
}

table.log-table tr:last-child td {
    border-bottom: none;
}

.badge {
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    display: inline-block;
}

.badge.create {
    background: var(--teal-soft);
    color: var(--teal);
}

.badge.update {
    background: #e8effd;
    color: #2563eb;
}

.badge.delete {
    background: var(--red-soft);
    color: var(--red);
}

.badge.login {
    background: #f1eefe;
    color: #7c3aed;
}

.log-user {
    font-weight: 600;
}

.log-time {
    color: var(--muted);
    font-size: 12px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--navy);
    color: #fff;
    padding: 13px 18px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    gap: 10px;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: .25s;
    z-index: 100;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast .tick {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 3px;
}

.section-desc {
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 14px;
}

/* ========== MOBILE / HP ========== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(280px, 85vw);
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.25);
    }

    .sidebar.collapsed {
        width: min(280px, 85vw);
        /* di mobile kita tidak pakai mode collapsed sempit */
    }

    .sidebar.collapsed .brand-text,
    .sidebar.collapsed .nav-group-label,
    .sidebar.collapsed .nav-item .label,
    .sidebar.collapsed .sidebar-footer .who {
        display: block;
    }

    .sidebar.collapsed .nav-item {
        justify-content: flex-start;
    }

    .sidebar.collapsed .nav-item.active::before {
        left: -12px;
    }

    .sidebar-backdrop {
        display: block;
    }

    .main {
        width: 100%;
        min-width: 0;
    }

    .topbar {
        padding: 12px 14px;
    }

    .topbar-title {
        font-size: 16px;
    }

    .topbar-crumb {
        font-size: 11.5px;
    }

    .pill {
        font-size: 11px;
        padding: 5px 9px;
    }

    .content {
        padding: 16px 12px 28px;
    }

    .page-head h1 {
        font-size: 19px;
    }

    .page-head p {
        font-size: 13px;
    }

    /* Grids → 1 kolom */
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr !important;
    }

    .stat-value {
        font-size: 22px;
    }

    .card-head {
        padding: 14px 16px;
        flex-wrap: wrap;
    }

    .card-body {
        padding: 16px;
    }

    /* Form & input lebih nyaman disentuh */
    input[type=text],
    input[type=number],
    input[type=search],
    select,
    textarea {
        padding: 11px 12px;
        font-size: 15px;
        /* cegah zoom iOS */
    }

    .btn {
        padding: 11px 16px;
        font-size: 14px;
        min-height: 42px;
    }

    .btn-sm {
        padding: 8px 12px;
        min-height: 36px;
    }

    .actions-bar {
        flex-direction: column-reverse;
        gap: 8px;
    }

    .actions-bar .btn {
        width: 100%;
        justify-content: center;
    }

    /* Area pengiriman */
    .loc-row,
    .loc-row-head {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }

    .loc-row-head {
        display: none;
        /* label sudah ada di placeholder */
    }

    .area-card-head {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .area-card-head>div:last-child {
        width: 100%;
        display: flex;
        gap: 8px;
    }

    .area-card-head .btn {
        flex: 1;
        justify-content: center;
    }

    /* Ongkir table */
    .row-table th,
    .row-table td {
        padding-left: 6px;
        padding-right: 6px;
    }

    /* Log table → horizontal scroll */
    .log-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .log-toolbar input {
        max-width: none;
    }

    table.log-table {
        min-width: 520px;
    }

    /* Day picker lebih besar */
    .day-toggle {
        width: 42px;
        height: 38px;
        font-size: 13px;
    }

    /* Toast */
    .toast {
        left: 12px;
        right: 12px;
        bottom: 16px;
        max-width: none;
    }

    /* Chip */
    .chip-wrap {
        gap: 6px;
    }
}

/* Tablet kecil */
@media (max-width: 980px) and (min-width: 769px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .content {
        padding: 22px 18px;
    }
}