:root {
    --primary: #ff5b1f;
    --primary-600: #ec4a0e;
    --primary-50: #fff1ea;
    --bg: #f4f4f6;
    --surface: #ffffff;
    --surface-soft: #fafafb;
    --border: #ececf0;
    --text: #17171f;
    --text-soft: #4b4b57;
    --muted: #82828e;
    --success: #12b76a;
    --success-bg: #e7f8ef;
    --danger: #f04438;
    --danger-bg: #fdeceb;
    --hover: #f5f5f7;
    --border-strong: #d8d8df;
    --track: #efeff3;
    --hatch-a: #e6e6eb;
    --hatch-b: #f5f5f8;
    --bar-soft: #ffd5c3;
    --ring-track: #ffe5d9;
    --heat-0: #f4f4f6;
    --heat-1: #ffe6da;
    --heat-2: #ffc2a6;
    --heat-3: #ff9466;
    --tooltip-bg: #17171f;
    --tooltip-muted: #b9b9c4;
    --radius: 16px;
    --radius-sm: 10px;
    --sidebar-width: 252px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
    color-scheme: light;
}

[data-theme='dark'] {
    --primary-50: rgba(255, 91, 31, 0.14);
    --bg: #0e0e13;
    --surface: #17171f;
    --surface-soft: #1d1d27;
    --border: #2a2a36;
    --text: #f1f1f5;
    --text-soft: #c5c5d0;
    --muted: #8b8b99;
    --success-bg: rgba(18, 183, 106, 0.16);
    --danger-bg: rgba(240, 68, 56, 0.16);
    --hover: #22222d;
    --border-strong: #3a3a48;
    --track: #2a2a36;
    --hatch-a: #30303d;
    --hatch-b: #22222c;
    --bar-soft: rgba(255, 91, 31, 0.3);
    --ring-track: rgba(255, 91, 31, 0.2);
    --heat-0: #22222c;
    --heat-1: rgba(255, 91, 31, 0.2);
    --heat-2: rgba(255, 91, 31, 0.42);
    --heat-3: rgba(255, 91, 31, 0.7);
    --tooltip-bg: #2c2c38;
    --tooltip-muted: #9d9dab;
    --shadow: none;
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

h1, h2, h3, p {
    margin: 0;
}

.icon {
    flex-shrink: 0;
}

/* ---------- Layout ---------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    padding: 20px 14px 16px;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: transform 0.25s ease;
}

.main {
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 22px 28px 36px;
}

.sidebar-backdrop {
    display: none;
}

/* ---------- Sidebar ---------- */

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 8px 18px;
}

.brand__logo {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: var(--text);
    color: var(--surface);
}

.brand__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand__name {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.brand__tagline {
    font-size: 12px;
    color: var(--muted);
}

.sidebar-search {
    position: relative;
    margin: 0 4px 18px;
}

.sidebar-search .icon {
    position: absolute;
    top: 50%;
    left: 12px;
    color: var(--muted);
    transform: translateY(-50%);
}

.sidebar-search input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 36px;
    font: inherit;
    color: var(--text);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, background 0.15s;
}

.sidebar-search input:focus {
    background: var(--surface);
    border-color: var(--primary);
}

.nav-section {
    margin-bottom: 16px;
}

.nav-section__label {
    padding: 0 12px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    margin-bottom: 2px;
    font-weight: 500;
    color: var(--text-soft);
    border-radius: var(--radius-sm);
    transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
    color: var(--text);
    background: var(--hover);
}

.nav-link.is-active {
    color: var(--primary);
    background: var(--primary-50);
    font-weight: 600;
}

.sidebar__footer {
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ---------- Topbar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: -22px -28px 22px;
    padding: 14px 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar__left,
.topbar__right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar__title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.topbar__date {
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
}

.profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 6px 6px;
    font: inherit;
    color: var(--text);
    text-align: left;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.avatar {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 36px;
    height: 36px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #ff9a6b, var(--primary));
    border-radius: 50%;
}

.profile__info {
    flex: 1;
    min-width: 0;
}

.profile__name,
.profile__role {
    display: block;
    white-space: nowrap;
}

.profile__name {
    font-size: 13px;
    font-weight: 600;
}

.profile__role {
    font-size: 12px;
    color: var(--muted);
}

/* ---------- User menu (dropdown) ---------- */

.user-menu {
    position: relative;
}

.user-menu__trigger {
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.user-menu__trigger:hover,
.user-menu.is-open .user-menu__trigger {
    border-color: var(--border-strong);
}

.user-menu__chevron {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    color: var(--muted);
    transition: transform 0.2s ease;
}

.user-menu.is-open .user-menu__chevron {
    transform: rotate(90deg);
}

.user-menu__panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 50;
    width: 240px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.user-menu.is-open .user-menu__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.user-menu__label {
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.theme-switch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    background: var(--bg);
    border-radius: 10px;
}

.theme-switch__option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.theme-switch__option:hover {
    color: var(--text);
}

.theme-switch__option.is-active {
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.theme-switch__option.is-active .icon {
    color: var(--primary);
}

.icon-btn {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--text-soft);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.icon-btn:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.icon-btn--sm {
    width: 32px;
    height: 32px;
}

.icon-btn .dot {
    position: absolute;
    top: 9px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border: 2px solid var(--surface);
    border-radius: 50%;
}

.menu-toggle {
    display: none;
}

/* ---------- Buttons & chips ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
    color: #fff;
    background: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-600);
}

.btn-dark {
    color: var(--surface);
    background: var(--text);
}

.btn-dark:hover {
    opacity: 0.88;
}

.btn-outline {
    color: var(--text);
    background: var(--surface);
    border-color: var(--border);
}

.btn-outline:hover {
    background: var(--surface-soft);
    border-color: var(--border-strong);
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
}

.btn-block {
    width: 100%;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-soft);
    background: var(--bg);
    border-radius: 999px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
}

.badge-success {
    color: var(--success);
    background: var(--success-bg);
}

.badge-danger {
    color: var(--danger);
    background: var(--danger-bg);
}

/* ---------- Toolbar ---------- */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.tabs {
    display: inline-flex;
    gap: 2px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.tab {
    padding: 7px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
}

.tab:hover {
    color: var(--text);
}

.tab.is-active {
    font-weight: 600;
    color: var(--text);
    background: var(--bg);
}

.toolbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar__updated {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}

/* ---------- Cards & grids ---------- */

.card {
    min-width: 0;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card__title {
    font-size: 15px;
    font-weight: 600;
}

.card__subtitle {
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.grid {
    display: grid;
    gap: 16px;
    margin-bottom: 16px;
}

.grid-performance {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
}

.grid-insight {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
}

/* ---------- Stat card ---------- */

.stat-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px 10px;
    padding-bottom: 0;
}

.stat-card__label {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.stat-card__value {
    margin: 8px 0 10px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.stat-card__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.stat-card__caption {
    font-size: 12px;
    color: var(--muted);
}

.stat-card__chart {
    display: flex;
    align-items: flex-end;
}

.stat-card__link {
    display: flex;
    grid-column: 1 / -1;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin: 0 -18px;
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    border-top: 1px solid var(--border);
    transition: color 0.15s;
}

.stat-card__link:hover {
    color: var(--primary);
}

.mini-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 58px;
}

.mini-bars span {
    width: 8px;
    background: var(--bar-soft);
    border-radius: 3px;
}

.mini-bars span.is-current {
    background: var(--primary);
}

.mini-ring {
    --value: 0;
    position: relative;
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    background: conic-gradient(var(--primary) calc(var(--value) * 1%), var(--ring-track) 0);
    border-radius: 50%;
}

.mini-ring::before {
    content: '';
    position: absolute;
    inset: 8px;
    background: var(--surface);
    border-radius: 50%;
}

.mini-ring span {
    position: relative;
    font-size: 12px;
    font-weight: 700;
}

/* ---------- Collection score (gauge) ---------- */

.score-card {
    display: flex;
    flex-direction: column;
}

.gauge {
    position: relative;
    width: 100%;
    max-width: 240px;
    margin: 0 auto;
}

.gauge svg {
    display: block;
    width: 100%;
    height: auto;
}

.gauge line {
    stroke: var(--track);
    stroke-width: 6;
    stroke-linecap: round;
}

.gauge line.is-on {
    stroke: var(--primary);
}

.gauge__value {
    position: absolute;
    right: 0;
    bottom: 2px;
    left: 0;
    text-align: center;
}

.gauge__value strong {
    display: block;
    font-size: 38px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.03em;
}

.gauge__value span {
    font-size: 12px;
    color: var(--muted);
}

.score-card__note {
    margin: 18px 0 16px;
    padding: 12px 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.score-card__headline {
    margin-bottom: 4px;
    font-weight: 600;
}

.score-card__description {
    font-size: 12px;
    color: var(--muted);
}

.score-card .btn {
    margin-top: auto;
}

/* ---------- Revenue bar chart ---------- */

.revenue-card {
    display: flex;
    flex-direction: column;
}

.select {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 10px;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.select select {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: transparent;
    border: 0;
    outline: none;
    cursor: pointer;
}

.bar-chart {
    display: flex;
    flex: 1;
    gap: 12px;
    min-height: 270px;
}

.bar-chart__axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 44px;
    padding: 24px 0 26px;
    font-size: 11px;
    color: var(--muted);
    text-align: right;
}

.bar-chart__axis span {
    line-height: 0;
}

.bar-chart__plot {
    position: relative;
    display: grid;
    flex: 1;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 10px;
}

.bar-chart__plot::before {
    content: '';
    position: absolute;
    inset: 24px 0 26px;
    background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px);
    background-size: 100% 25%;
    border-bottom: 1px solid var(--border);
    pointer-events: none;
}

.bar-chart__col {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.bar-chart__track {
    display: flex;
    flex: 1;
    align-items: flex-end;
    justify-content: center;
    padding-top: 24px;
}

.bar-chart__bar {
    position: relative;
    width: 100%;
    max-width: 40px;
    min-height: 4px;
    background: repeating-linear-gradient(135deg, var(--hatch-a) 0 2px, var(--hatch-b) 2px 7px);
    border-radius: 8px 8px 4px 4px;
    transition: background 0.2s;
}

.bar-chart__col:hover .bar-chart__bar {
    background: #ffb796;
}

.bar-chart__col.is-active .bar-chart__bar {
    background: var(--primary);
}

.bar-chart__label {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 26px;
    font-size: 12px;
    color: var(--muted);
}

.bar-chart__col.is-active .bar-chart__label {
    font-weight: 600;
    color: var(--text);
}

.chart-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    z-index: 5;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    font-size: 12px;
    white-space: nowrap;
    color: #fff;
    background: var(--tooltip-bg);
    border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%);
    transition: opacity 0.15s;
}

.chart-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    border: 6px solid transparent;
    border-top-color: var(--tooltip-bg);
    transform: translateX(-50%);
}

.chart-tooltip__title {
    font-size: 11px;
    color: var(--tooltip-muted);
}

.chart-tooltip__row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.bar-chart__col.is-active .chart-tooltip {
    opacity: 1;
}

.bar-chart__plot:hover .bar-chart__col.is-active .chart-tooltip {
    opacity: 0;
}

.bar-chart__plot .bar-chart__col:hover .chart-tooltip {
    opacity: 1;
}

/* ---------- Ticket heatmap ---------- */

.heat-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
}

.heat-legend i {
    display: inline-block;
    width: 16px;
    height: 10px;
    border-radius: 3px;
}

.heatmap {
    display: grid;
    grid-template-columns: 52px repeat(var(--cols), minmax(0, 1fr));
    align-items: center;
    gap: 6px;
}

.heatmap__day {
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

.heatmap__slot {
    font-size: 12px;
    color: var(--muted);
}

.heatmap__cell {
    height: 40px;
    border-radius: 8px;
    transition: transform 0.15s, box-shadow 0.15s;
}

.heatmap__cell:hover {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
    transform: scale(1.04);
}

.heat-0 { background: var(--heat-0); }
.heat-1 { background: var(--heat-1); }
.heat-2 { background: var(--heat-2); }
.heat-3 { background: var(--heat-3); }
.heat-4 { background: var(--primary); }

/* ---------- Package distribution ---------- */

.package-card__body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.package-card__summary {
    flex: 1;
    min-width: 0;
}

.package-card__total {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.legend i {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 3px;
}

.legend__label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    color: var(--text-soft);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pie {
    flex-shrink: 0;
    width: 156px;
    height: 156px;
    border-radius: 50%;
}

/* ---------- Alerts ---------- */

.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
}

.alert span {
    flex: 1;
}

.alert-success {
    color: var(--success);
    background: var(--success-bg);
    border-color: rgba(18, 183, 106, 0.25);
}

.alert-danger {
    color: var(--danger);
    background: var(--danger-bg);
    border-color: rgba(240, 68, 56, 0.25);
}

.alert-warning {
    color: #b45309;
    background: rgba(217, 119, 6, 0.1);
    border-color: rgba(217, 119, 6, 0.25);
}

.alert__close {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
}

.alert__close:hover {
    background: rgba(0, 0, 0, 0.06);
}

/* ---------- Dropdown ---------- */

.dropdown {
    position: relative;
}

.dropdown__panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 30;
    min-width: 200px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}

.dropdown.is-open .dropdown__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
}

.dropdown__item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    font-weight: 500;
    color: var(--text-soft);
    border-radius: 8px;
}

button.dropdown__item {
    width: 100%;
    font: inherit;
    font-weight: 500;
    text-align: left;
    background: transparent;
    border: 0;
    cursor: pointer;
}

.dropdown__item:hover {
    color: var(--primary);
    background: var(--primary-50);
}

.dropdown__badge {
    display: grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    margin-left: auto;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: var(--primary);
    border-radius: 999px;
}

/* ---------- Modal ---------- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
}

.modal[hidden] {
    display: none;
}

.modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 20, 0.45);
    animation: fade-in 0.15s ease;
}

.modal__dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    animation: pop-in 0.18s ease;
}

.modal__header,
.modal__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px;
}

.modal__header {
    border-bottom: 1px solid var(--border);
}

.modal__footer {
    border-top: 1px solid var(--border);
}

.modal__body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
}

@keyframes fade-in {
    from { opacity: 0; }
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
}

/* ---------- Confirm (hapus) ---------- */

.btn-danger {
    color: #fff;
    background: var(--danger);
}

.btn-danger:hover {
    background: #d92d20;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.confirm-card {
    max-width: 560px;
    padding: 28px;
    text-align: center;
}

.confirm-card__icon {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    color: var(--danger);
    background: var(--danger-bg);
    border-radius: 50%;
}

.confirm-card__title {
    font-size: 18px;
    font-weight: 700;
}

.confirm-card__text {
    margin: 6px 0 18px;
    color: var(--muted);
}

.confirm-card .alert {
    text-align: left;
}

.confirm-card__actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.detail-list {
    margin: 0 0 18px;
    padding: 4px 16px;
    text-align: left;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.detail-list div {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}

.detail-list div:last-child {
    border-bottom: 0;
}

.detail-list dt {
    color: var(--muted);
}

.detail-list dd {
    margin: 0;
    font-weight: 500;
}

/* ---------- Forms ---------- */

.input {
    width: 100%;
    height: 40px;
    padding: 0 12px;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

textarea.input {
    height: auto;
    min-height: 72px;
    padding: 10px 12px;
    resize: vertical;
}

.input::placeholder {
    color: var(--muted);
    opacity: 0.8;
}

.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.input--select {
    width: auto;
    min-width: 160px;
    cursor: pointer;
}

.input-icon {
    position: relative;
    display: block;
    flex: 1;
    min-width: 220px;
}

.input-icon .icon {
    position: absolute;
    top: 50%;
    left: 12px;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.input-icon .input {
    padding-left: 36px;
}

.btn-ghost {
    color: var(--muted);
    background: transparent;
}

.btn-ghost:hover {
    color: var(--text);
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-card {
    padding: 20px;
}

.form-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.form-card__icon {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 38px;
    height: 38px;
    color: var(--primary);
    background: var(--primary-50);
    border-radius: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    align-content: start;
}

.form-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field--full {
    grid-column: 1 / -1;
}

.field__label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
}

.field__required {
    color: var(--danger);
}

.field__hint,
.field__error {
    margin-top: 5px;
    font-size: 12px;
}

.field__hint {
    color: var(--muted);
}

.field__error {
    color: var(--danger);
}

.field.has-error .input {
    border-color: var(--danger);
}

.input-prefix {
    position: relative;
    display: block;
}

.input-prefix__label {
    position: absolute;
    top: 50%;
    left: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.input-prefix .input {
    padding-left: 40px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.form-actions__back {
    margin-right: auto;
}

.form-card__header--split {
    justify-content: space-between;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: 0;
}

.choice-group {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.choice {
    cursor: pointer;
}

.choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.choice__body {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    height: 100%;
    padding: 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.choice:hover .choice__body {
    border-color: var(--border-strong);
}

.choice input:checked + .choice__body {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-50);
}

.choice input:focus-visible + .choice__body {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.choice__icon {
    display: grid;
    flex-shrink: 0;
    place-items: center;
    width: 34px;
    height: 34px;
    color: var(--muted);
    background: var(--surface-soft);
    border-radius: 8px;
}

.choice input:checked + .choice__body .choice__icon {
    color: var(--primary);
    background: var(--primary-50);
}

.choice__title {
    display: block;
    font-weight: 600;
}

.choice__desc {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.source-panel {
    margin-top: 16px;
}

.source-panel[hidden] {
    display: none;
}

.link {
    font-weight: 600;
    color: var(--primary);
}

.link:hover {
    text-decoration: underline;
}

/* ---------- Address map ---------- */

.address-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 20px;
}

.map-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.map-search {
    display: flex;
    gap: 8px;
}

.map-search .input-icon {
    min-width: 0;
}

.map {
    flex: 1;
    min-height: 320px;
    overflow: hidden;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

[data-theme='dark'] .map .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9);
}

.map-status {
    font-size: 12px;
    color: var(--muted);
}

.map-status[data-tone='success'] { color: var(--success); }
.map-status[data-tone='warning'] { color: #d97706; }
.map-status[data-tone='danger'] { color: var(--danger); }

/* ---------- Page header & type picker ---------- */

.page-header {
    margin-bottom: 18px;
}

.page-header__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--muted);
}

.breadcrumb a:hover {
    color: var(--primary);
}

.breadcrumb span {
    color: var(--text);
    font-weight: 500;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.type-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    max-width: 880px;
    margin-bottom: 20px;
}

.type-option {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.type-option:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-50);
    transform: translateY(-2px);
}

.type-option__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    color: var(--primary);
    background: var(--primary-50);
    border-radius: 12px;
}

.type-option__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 700;
}

.type-option__desc {
    color: var(--muted);
}

.type-option__cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: auto;
    padding-top: 6px;
    font-weight: 600;
    color: var(--primary);
}

/* ---------- Table ---------- */

.table-card {
    padding: 0;
}

.table-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 18px 0;
}

.table-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    padding: 11px 18px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--muted);
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 12px 18px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table tbody tr:hover {
    background: var(--surface-soft);
}

.table-empty {
    padding: 40px 18px !important;
    text-align: center;
    color: var(--muted);
}

.table-card__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
}

.cell-customer {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cell-title {
    font-weight: 600;
}

.cell-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.cell-nowrap {
    white-space: nowrap;
}

.table__actions {
    width: 1%;
    text-align: right !important;
    white-space: nowrap;
}

.row-actions {
    display: inline-flex;
}

.row-action {
    position: relative;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    color: var(--text-soft);
    border: 1px solid var(--border);
    transition: color 0.15s, background 0.15s;
}

.row-action + .row-action {
    margin-left: -1px;
}

.row-action:first-child {
    border-radius: 8px 0 0 8px;
}

.row-action:last-child {
    border-radius: 0 8px 8px 0;
}

.row-action:hover {
    z-index: 1;
    color: var(--primary);
    background: var(--primary-50);
}

.row-action--danger:hover {
    color: var(--danger);
    background: var(--danger-bg);
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-50);
    border-radius: var(--radius-sm);
}

.avatar--sm {
    width: 34px;
    height: 34px;
    font-size: 12px;
}

.avatar--company {
    background: linear-gradient(135deg, #6b7280, #374151);
}

.type-tag {
    display: inline-flex;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--primary);
    background: var(--primary-50);
    border-radius: 5px;
}

.type-tag--company {
    color: #4f46e5;
    background: rgba(79, 70, 229, 0.12);
}

.status {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 999px;
}

.service-type {
    display: inline-flex;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    border-radius: 999px;
}

.service-type--infrastructure { color: #4f46e5; background: rgba(79, 70, 229, 0.12); }
.service-type--internet { color: var(--primary); background: var(--primary-50); }
.service-type--managed_service { color: #0e9384; background: rgba(14, 147, 132, 0.12); }

.source-tag {
    display: inline-flex;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #d97706;
    background: rgba(217, 119, 6, 0.12);
    border-radius: 5px;
}

.cell-truncate {
    display: block;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-money {
    font-weight: 600;
    white-space: nowrap;
}

.detail-list__text {
    white-space: pre-line;
}

.status--active { color: var(--success); background: var(--success-bg); }
.status--pending { color: #d97706; background: rgba(217, 119, 6, 0.12); }
.status--suspended { color: var(--danger); background: var(--danger-bg); }
.status--terminated { color: var(--muted); background: var(--track); }

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination__item {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-soft);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.pagination__item:hover {
    border-color: var(--border-strong);
}

.pagination__item.is-active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}

.pagination__item.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.pagination__gap {
    padding: 0 4px;
    color: var(--muted);
}

/* ---------- Error pages ---------- */

.is-blank {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.error-page {
    max-width: 560px;
    text-align: center;
}

.error-page__code {
    font-size: 72px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--primary);
}

.error-page__title {
    margin: 12px 0 8px;
    font-size: 22px;
}

.error-page__text {
    margin-bottom: 20px;
    color: var(--muted);
}

.error-page__hint {
    margin-bottom: 16px;
    padding: 12px 14px;
    text-align: left;
    color: #8a3b12;
    background: var(--primary-50);
    border: 1px solid #ffd2bd;
    border-radius: var(--radius-sm);
}

.error-page__trace {
    margin: 0 0 20px;
    padding: 14px;
    overflow-x: auto;
    font-size: 12px;
    text-align: left;
    white-space: pre-wrap;
    color: #f3f3f6;
    background: var(--tooltip-bg);
    border-radius: var(--radius-sm);
}

/* ---------- Responsive ---------- */

@media (max-width: 1320px) {
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    .grid-performance,
    .grid-insight,
    .address-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 920px) {
    .sidebar {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar {
        transform: none;
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 30;
        display: block;
        background: rgba(15, 15, 20, 0.35);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s;
    }

    body.sidebar-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .main {
        margin-left: 0;
        padding: 16px;
    }

    .topbar {
        margin: -16px -16px 16px;
        padding: 12px 16px;
    }

    .menu-toggle {
        display: grid;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .user-menu__trigger .profile__info,
    .toolbar__updated {
        display: none;
    }

    .form-grid,
    .form-grid--3,
    .type-grid,
    .choice-group {
        grid-template-columns: minmax(0, 1fr);
    }

    .form-actions {
        flex-wrap: wrap;
    }

    .input--select {
        flex: 1;
    }

    .bar-chart__plot {
        gap: 4px;
    }

    .bar-chart__label {
        font-size: 10px;
    }

    .heatmap__cell {
        height: 30px;
    }

    .package-card__body {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .pie {
        align-self: center;
    }
}
