@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --sidebar-bg:          #1A2035;
    --sidebar-border:      rgba(255,255,255,0.06);
    --sidebar-text:        #8896AB;
    --sidebar-hover-bg:    rgba(255,255,255,0.05);
    --sidebar-active-bg:   rgba(102,68,255,0.14);
    --sidebar-active-text: #A78BFF;
    --accent:              #6644FF;
    --accent-hover:        #5533EE;
    --bg:                  #F1F3FB;
    --surface:             #FFFFFF;
    --border:              #E2E8F0;
    --text:                #1E293B;
    --text-muted:          #64748B;
    --text-faint:          #94A3B8;
    --radius-sm:           3px;
    --radius:              5px;
    --radius-lg:           5px;
    --shadow-sm:           none;
    --shadow:              none;
}

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

/* ── Scrollbars ──────────────────────────────────────────── */

* {
    scrollbar-width: thin;
    scrollbar-color: rgba(148,163,184,0.4) transparent;
}

*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: rgba(148,163,184,0.35);
    border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(148,163,184,0.6); }

#aside::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); }
#aside::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

html, body {
    height: 100%;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

body {
    display: flex;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────── */

#aside {
    width: max-content;
    min-width: 180px;
    flex-shrink: 0;
    height: 100%;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
}

#aside nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 72px;
    padding: 0 18px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}

.brand-logo {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-logo svg { display: block; }

.brand-name {
    font-size: 13px;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.nav-section {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sidebar-text);
    padding: 20px 18px 8px;
}

#aside ul {
    list-style: none;
    padding: 8px 8px 8px;
}

#aside ul li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px 9px 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 13px;
    font-weight: 500;
    _transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

#aside ul li a:hover {
    background: var(--sidebar-hover-bg);
    color: #FFFFFF;
}

#aside ul li.active a {
    background: var(--sidebar-active-bg);
    color: #FFFFFF;
}

.nav-icon {
    flex-shrink: 0;
    opacity: 0.45;
    _transition: opacity 0.15s;
}

#aside ul li.active .nav-icon,
#aside ul li a:hover .nav-icon { opacity: 1; }

.nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-count {
    flex-shrink: 0;
    margin-left: 16px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.06);
    padding: 1px 6px;
    border-radius: 20px;
    font-variant-numeric: tabular-nums;
    _transition: color 0.15s, background 0.15s;
}

#aside ul li a:hover .nav-count {
    color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.1);
}

#aside ul li.active .nav-count {
    color: rgba(255,255,255,0.7);
    background: rgba(102,68,255,0.3);
}

/* ── Main ────────────────────────────────────────────────── */

#main {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.content-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 72px;
    padding: 0 24px;
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-content: center;
    column-gap: 0px;
}

.content-header .breadcrumb {
    grid-column: 1;
    grid-row: 1;
    margin-bottom: 2px;
}

.content-header .header-row {
    grid-column: 1;
    grid-row: 2;
    padding-bottom: 0;
}

.content-header .search-wrap {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-faint);
    margin-bottom: 2px;
}

.breadcrumb a {
    color: var(--text-faint);
    text-decoration: none;
    _transition: color 0.15s;
}

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

.breadcrumb .sep { color: var(--border); }

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

.header-row #mobile-top-actions {
    margin-top: -20px;
    @media(max-width: 768px) {
        margin-top: 0px;
    }
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
}

.header-row h1 {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
    background: var(--border);
    padding: 2px 8px;
    border-radius: 20px;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    color: var(--text-faint);
    _transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap:focus-within {
    border-color: var(--accent);
    color: var(--text-muted);
}

.search-wrap input {
    border: none;
    outline: none;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: transparent;
    width: 200px;
}

.search-wrap input::placeholder { color: var(--text-faint); }

.content-body {
    padding: 24px;
    flex: 1;
    .card-error {
        h1 {
            color:black;
            margin-bottom: 15px;
        }
        .btn-primary {
            margin-top: 35px;
        }
    }
}

/* ── Card ────────────────────────────────────────────────── */

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: clip;
}

.card-error {
    width: 500px;
    margin: 0px auto;
}

/* ── Overview table ──────────────────────────────────────── */

table.overview {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.card--table {
    cursor: grab;
    user-select: none;
}
.card--table.is-dragging { cursor: grabbing; }

.table-scroll {
    max-height: calc(100vh - 72px - 24px - 27px);
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 #F1F3FB;
}

.table-scroll::-webkit-scrollbar        { width: 6px; height: 14px; }
.table-scroll::-webkit-scrollbar-track  { background: #F1F3FB; }
.table-scroll::-webkit-scrollbar-track:horizontal { border-top: 1px solid var(--border); }
.table-scroll::-webkit-scrollbar-thumb  { background: #CBD5E1; border-radius: 99px; border: 3px solid #F1F3FB; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #94A3B8; }

table.overview thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--surface);
    color: var(--text);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.overview thead th.sortable {
    cursor: pointer;
    user-select: none;
}

table.overview thead th.sortable:hover { color: var(--text); }

table.overview thead th.sort-asc::after,
table.overview thead th.sort-desc::after {
    content: '';
    display: inline-block;
    margin-left: 5px;
    width: 0;
    height: 0;
    vertical-align: middle;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
}

table.overview thead th.sort-asc::after {
    border-bottom: 4px solid var(--accent);
}

table.overview thead th.sort-desc::after {
    border-top: 4px solid var(--accent);
}

table.overview thead th:last-child,
table.overview tbody td:last-child {
    position: sticky;
    right: 0;
}

table.overview thead th:last-child { background: var(--surface); z-index: 6; }

table.overview tbody td:last-child { background: #FFFFFF; }

table.overview tbody tr:hover td:last-child { background: #F5F7FF; }

table.overview tbody td {
    border-bottom: 1px solid var(--border);
}

table.overview tbody tr:last-child td { border-bottom: none; }

table.overview tbody tr:hover { background: #F5F7FF; }

table.overview tbody td {
    padding: 12px 16px;
    color: var(--text);
    vertical-align: middle;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

table.overview tbody td:first-child {
    font-variant-numeric: tabular-nums;
}

.btn-edit {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: rgba(102,68,255,0.06);
    border: 1px solid rgba(102,68,255,0.15);
    _transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.btn-edit:hover {
    background: rgba(102,68,255,0.12);
    border-color: rgba(102,68,255,0.3);
}

/* ── Buttons ─────────────────────────────────────────────── */

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    padding: 9px 10px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    _transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { opacity: 0.9; }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    _transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-secondary:hover {
    background: var(--bg);
    color: var(--text);
    border-color: #CBD5E1;
}

/* ── Edit form ───────────────────────────────────────────── */

.field-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.field input[type="text"],
.field input[type="password"] {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    font-family: 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;
}

.field textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
}

.field input[type="text"]:focus,
.field input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(102,68,255,0.12);
}

.field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(102,68,255,0.12);
    outline:none!important;
}

.field input[type="text"]:disabled,
.field input[type="password"]:disabled {
    background: #F8F9FC;
    color: var(--text-faint);
    cursor: not-allowed;
    border-color: var(--border);
}

.field textarea:disabled {
    background: #F8F9FC;
    color: var(--text-faint);
    cursor: not-allowed;
    border-color: var(--border);
}

.field-hint {
    font-size: 11px;
    color: var(--text-faint);
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: #FAFBFC;
}

/* ── Notice / alert ──────────────────────────────────────── */

.notice {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    background: #166534;
    border: 1px solid #166534;
    padding: 15px;
    border-radius: var(--radius);
    margin: 0 25px 0;
    margin-top: 25px;
}
.notice-deleted {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    background: #166534;
    border: 1px solid #166534;
    padding: 15px;
    border-radius: var(--radius);
    margin: 0 25px 0;
    margin-top: 25px;
}
.notice-login {
    margin: 0 22px 0!important;
    margin-bottom: 30px!important;
    color: white;
    border: 1px solid #D93232;;
    background: #D93232;
}

/* ── Empty / placeholder states ──────────────────────────── */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 96px 32px;
    gap: 8px;
    color: var(--text-faint);
    text-align: center;
}

.empty-state svg { margin-bottom: 8px; }

.empty-state p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ── Menu button (mobile only) ───────────────────────────── */

.menu-btn {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 52px;
    height: 56px;
    z-index: 300;
    background: var(--surface);
    border: none;
    border-bottom: none;
    color: var(--text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 199;
}

.sidebar-overlay.open { display: block; }

/* ── Mobile ──────────────────────────────────────────────── */

@media (max-width: 768px) {

    .brand {
        display: flex;
        align-items: center;
        gap: 10px;
        height: 72px;
        padding: 0 18px;
        flex-shrink: 0;
        border-bottom: 1px solid var(--sidebar-border);
        text-decoration: none;
        padding-left: 50px;
    }
    .menu-btn { display: flex; }

    #aside {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        z-index: 200;
        width: 260px;
        display: none;
        border-right: 1px solid rgba(255,255,255,0.08);
    }

    #aside.open { display: flex; }

    /* Tuck the menu button inside the sidebar brand area when open */
    #aside.open ~ * .menu-btn,
    body:has(#aside.open) .menu-btn {
        z-index: 201;
        background: transparent;
        border-bottom-color: transparent;
        margin-top: 8px;
    }

    #main { width: 100%; min-width: 0; }

    /* App bar: single row, hamburger already occupies left 52px via fixed */
    .content-header {
        display: flex;
        flex-direction: column;
        height: auto;
        padding: 0;
    }

    .content-header .breadcrumb { display: none; }

    .content-header .header-row {
        display: flex;
        align-items: center;
        height: 56px;
        padding: 0 16px 0 60px;
        border-bottom: none;
        padding-bottom: 0;
    }

    .header-row h1 { font-size: 15px; }

    /* Full-width search bar below the title row */
    .content-header .search-wrap {
        grid-column: unset;
        grid-row: unset;
        align-self: unset;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        border-bottom: none;
        padding: 13px 16px;
        border-top: 1px solid #e2e8f0;
    }

    .search-wrap input { width: 100%; }

    .content-body { padding: 12px; }

    .table-scroll { 
        max-height: calc(100vh - 56px - 45px - 24px - 0px);
    }

    .field-grid   { padding: 16px; }
    .form-actions { padding: 12px 16px; }

    .notice { 
        margin: 0 12px 12px;
        margin-top: 22px;
    }

    .notice-login {
        margin: 0 17px 0 !important;
        margin-bottom: 17px !important;
        color: #651616;
        border: 1px solid #f7bbbb;
        background: #fdf0f0;
    }


    .btn-primary, .btn-secondary { padding: 8px 14px; font-size: 12px; }
}
