:root {
    --bg: #0f131a;
    --panel: #171d27;
    --panel-soft: #1e2634;
    --line: #2a3548;
    --text: #edf2f7;
    --muted: #96a2b5;
    --accent: #1ec8a5;
    --accent-soft: rgba(30, 200, 165, 0.16);
    --warning: #ffb703;
    --danger: #ff6363;
    --info: #5ec9ff;
    --ok: #67d981;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Noto Sans", sans-serif;
    background: radial-gradient(circle at 10% 0%, #172436 0%, var(--bg) 45%), var(--bg);
    color: var(--text);
    min-height: 100vh;
}

a {
    color: var(--info);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr;
}

.topbar {
    border-bottom: 1px solid var(--line);
    background: rgba(10, 14, 22, 0.85);
    backdrop-filter: blur(6px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-inner {
    max-width: 1500px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand img {
    width: 34px;
    height: 34px;
}

.notif-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--panel-soft);
    font-size: 1.05rem;
    line-height: 1;
    text-decoration: none;
}

.notif-link:hover {
    border-color: rgba(30, 200, 165, 0.45);
    background: rgba(30, 200, 165, 0.12);
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a {
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.92rem;
}

.nav a:hover,
.nav a.active {
    color: var(--text);
    background: var(--panel-soft);
    border-color: var(--line);
    text-decoration: none;
}

.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

.page {
    max-width: 1500px;
    margin: 0 auto;
    width: 100%;
    padding: 22px 20px 30px;
}

h1,
h2,
h3 {
    margin: 0;
}

.page-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.page-header h1 {
    font-size: 1.45rem;
    letter-spacing: 0.01em;
}

.page-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.grid {
    display: grid;
    gap: 14px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.panel {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.01), rgba(255, 255, 255, 0)), var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
}

.panel h3 {
    font-size: 1rem;
    margin-bottom: 10px;
}

.kpi {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.01);
}

.card-link {
    display: block;
    color: inherit;
}

.card-link:hover {
    text-decoration: none;
}

.kpi.interactive {
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.kpi.interactive:hover {
    border-color: rgba(30, 200, 165, 0.55);
    background: rgba(30, 200, 165, 0.08);
    transform: translateY(-1px);
}

.kpi .value {
    font-size: 1.4rem;
    font-weight: 700;
}

.kpi .label {
    color: var(--muted);
    font-size: 0.85rem;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(103, 217, 129, 0.15);
    color: var(--ok);
}

.badge-warning {
    background: rgba(255, 183, 3, 0.15);
    color: var(--warning);
}

.badge-danger {
    background: rgba(255, 99, 99, 0.16);
    color: var(--danger);
}

.badge-info {
    background: rgba(94, 201, 255, 0.16);
    color: var(--info);
}

.badge-muted {
    background: rgba(255, 255, 255, 0.09);
    color: var(--muted);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
}

label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    margin-bottom: 5px;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    background: #121825;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px 10px;
}

textarea {
    min-height: 80px;
    resize: vertical;
}

button,
.btn {
    border: 1px solid transparent;
    border-radius: 9px;
    padding: 9px 13px;
    font-weight: 600;
    background: var(--accent);
    color: #08231d;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

button:hover,
.btn:hover {
    opacity: 0.92;
}

.btn-soft {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: rgba(30, 200, 165, 0.35);
}

.btn-warning {
    background: rgba(255, 183, 3, 0.22);
    color: var(--warning);
    border-color: rgba(255, 183, 3, 0.4);
}

.btn-danger {
    background: rgba(255, 99, 99, 0.2);
    color: var(--danger);
    border-color: rgba(255, 99, 99, 0.35);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

th,
td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.excel-sheet {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: #0e1420;
}

.excel-grid-wrap {
    overflow: auto;
    max-height: 58vh;
}

.excel-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.9rem;
    background: #0f1624;
}

.excel-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #1a2436;
    color: #b6c3d8;
    border: 1px solid #2b3a55;
    padding: 8px 10px;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.excel-table td {
    border: 1px solid #23324b;
    padding: 7px 9px;
    color: #e6edf7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #0f1624;
}

.excel-table .bulk-input {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    color: inherit;
    padding: 4px 5px;
    border-radius: 4px;
}

.excel-table .bulk-input:disabled {
    opacity: 1;
    color: inherit;
    cursor: default;
}

.excel-table .bulk-input:not(:disabled) {
    background: #111f35;
    border-color: #2e4a74;
}

.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.btn-tool {
    border-radius: 10px;
    padding: 8px 14px;
    border: 1px solid transparent;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.1;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.12s ease, filter 0.12s ease, border-color 0.12s ease;
}

.btn-tool:hover {
    text-decoration: none;
    transform: translateY(-1px);
    filter: brightness(1.05);
}

.btn-tool:focus-visible {
    outline: 2px solid rgba(94, 201, 255, 0.65);
    outline-offset: 1px;
}

.btn-tool-primary {
    background: linear-gradient(180deg, #33d6b8 0%, #1fc8a5 100%);
    color: #052019;
    border-color: #3be0c1;
}

.btn-tool-secondary {
    background: #142236;
    color: #8ed7ff;
    border-color: #2b4f72;
}

.btn-tool-edit {
    background: #102f35;
    color: #5fe9d3;
    border-color: #2c7a79;
}

.btn-tool-add {
    background: #103034;
    color: #66e8d5;
    border-color: #2d7a73;
}

.btn-tool-save {
    background: linear-gradient(180deg, #45e0c4 0%, #25c8a8 100%);
    color: #032019;
    border-color: #58ebd2;
}

.excel-table tbody tr:nth-child(even) td {
    background: #101a2a;
}

.excel-table tbody tr:hover td {
    background: #152238;
}

.excel-table tbody tr.selected td {
    background: #183055;
}

.flash-wrap {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.flash {
    border-radius: 9px;
    border: 1px solid var(--line);
    padding: 10px 12px;
    font-size: 0.9rem;
}

.flash-success {
    border-color: rgba(103, 217, 129, 0.45);
    background: rgba(103, 217, 129, 0.12);
}

.flash-error {
    border-color: rgba(255, 99, 99, 0.4);
    background: rgba(255, 99, 99, 0.12);
}

.flash-warning {
    border-color: rgba(255, 183, 3, 0.45);
    background: rgba(255, 183, 3, 0.12);
}

.flash-info {
    border-color: rgba(94, 201, 255, 0.45);
    background: rgba(94, 201, 255, 0.12);
}

.inline-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.small {
    font-size: 0.84rem;
    color: var(--muted);
}

.quick-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.quick-card {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px;
    display: grid;
    gap: 6px;
    background: rgba(255, 255, 255, 0.01);
    color: inherit;
}

.quick-card:hover {
    text-decoration: none;
    border-color: rgba(30, 200, 165, 0.55);
    background: rgba(30, 200, 165, 0.08);
}

.quick-card-title {
    color: var(--text);
    font-weight: 700;
}

.map-box {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--line);
    min-height: 390px;
}

#map {
    height: 430px;
    width: 100%;
}

.clock-screen {
    text-align: center;
    padding: 24px;
}

.clock-time {
    font-size: clamp(2.5rem, 8vw, 5.8rem);
    font-weight: 700;
    letter-spacing: 0.04em;
}

.clock-date {
    color: var(--muted);
    margin-top: 4px;
}

@media (max-width: 900px) {
    .topbar-inner {
        flex-wrap: wrap;
    }

    .topbar-user {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }
}

details.custom-details {
    position: relative;
}

details.custom-details>summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    display: inline-block;
}

details.custom-details>summary::-webkit-details-marker {
    display: none;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--muted);
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    user-select: none;
}

.tab-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px 6px 0 0;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.sub-navbar {
    position: sticky;
    top: 64px;
    z-index: 9;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: 0 20px;
    /* Removed top/bottom padding to let tabs sit on the line */
    backdrop-filter: blur(8px);
    background: rgba(15, 19, 26, 0.95);
    width: 100%;
}

.sub-navbar-inner {
    display: flex;
    gap: 2px;
    /* Small gap for tabs */
    flex-wrap: wrap;
    max-width: 1500px;
    margin: 0 auto;
    height: 100%;
    /* Ensure full height */
    align-items: flex-end;
    /* Align tabs to bottom border */
}

.dropdown-menu {
    position: relative;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    min-width: 300px;
    z-index: 20;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar Icons */
.icon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    vertical-align: middle;
}

/* ── Toolbar (search + filters bar used in all list views) ─────────────── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 14px;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── form-control (styled input/select used in toolbars and forms) ──────── */
.form-control {
    background: #121825;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    font-size: 0.9rem;
    width: 100%;
    transition: border-color 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: rgba(30, 200, 165, 0.55);
}

/* ── Utility classes ────────────────────────────────────────────────────── */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-muted {
    color: var(--muted);
}

.text-accent {
    color: var(--accent);
}

.text-danger {
    color: var(--danger);
}

.text-ok {
    color: var(--ok);
}

.text-warning {
    color: var(--warning);
}

.p-2 {
    padding: 8px;
}

.p-3 {
    padding: 12px;
}

.mt-1 {
    margin-top: 6px;
}

.mt-2 {
    margin-top: 12px;
}

.mb-1 {
    margin-bottom: 6px;
}

.mb-2 {
    margin-bottom: 12px;
}

/* ── Pagination ─────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    padding: 14px 0 4px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 0.88rem;
    text-decoration: none;
    transition: border-color 0.12s, background 0.12s;
}

.pagination a:hover {
    border-color: rgba(30, 200, 165, 0.45);
    background: rgba(30, 200, 165, 0.08);
    color: var(--accent);
    text-decoration: none;
}

.pagination .active {
    border-color: rgba(30, 200, 165, 0.5);
    background: rgba(30, 200, 165, 0.12);
    color: var(--accent);
    font-weight: 700;
}

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    margin: 0;
    font-size: 0.95rem;
}

/* ── btn-main (primary action button) ──────────────────────────────────── */
.btn-main {
    background: var(--accent);
    color: #08231d;
    border: none;
    border-radius: 9px;
    padding: 9px 14px;
    font-weight: 700;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-block;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-main:hover {
    opacity: 0.88;
    text-decoration: none;
}

/* ── List item ──────────────────────────────────────────────────────────── */
.list-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    transition: background 0.12s;
}

.list-item:last-child {
    border-bottom: none;
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* ── grid-4 for dashboard ───────────────────────────────────────────────── */
.grid-4 {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.grid-6 {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}