/* ======================= */
/* RESET & BASE            */
/* ======================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f3f5f9;
    color: #1f2430;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
    line-height: 1.45;
}

/* ======================= */
/* LAYOUT                  */
/* ======================= */
#app {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #0b1220;
    color: #f0f4fa;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #0e1a30;
    transition: transform .22s ease, width .22s ease, opacity .22s ease;
    z-index: 30;
}
.sidebar:not(.open) {
    width: 0;
    transform: translateX(-100%);
    opacity: 0;
    overflow: hidden;
    border-right-width: 0;
}

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

.views {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(8px) saturate(140%);
    -webkit-backdrop-filter: blur(8px) saturate(140%);
    border-bottom: 1px solid #e6eaf1;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
}

/* ======================= */
/* SIDEBAR                 */
/* ======================= */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    background: #22c55e;
    color: #0b1220;
    border-radius: 8px;
    font-weight: 800;
    font-size: 16px;
}
.logo-text { font-size: 14px; letter-spacing: .3px; }

.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(180deg,rgba(255,255,255,.08),rgba(255,255,255,.03));
    margin: 8px 10px 6px;
    border-radius: 12px;
}
.avatar {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: #1f3a5f;
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #e8f0ff;
}
.profile-name { font-size: 13px; font-weight: 600; }
.profile-role { font-size: 11px; opacity: .7; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    color: #c8d4e3;
    text-decoration: none;
    transition: background .18s, color .18s;
}
.nav-item:hover { background: #1a2a42; color: white; }
.nav-item.active {
    background: #22c55e;
    color: #06120d;
    font-weight: 600;
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 16px;
    opacity: .55;
    font-size: 11px;
}

/* ======================= */
/* TOPBAR                  */
/* ======================= */
.topbar-title {
    font-size: 16px;
    font-weight: 600;
}
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.icon-btn {
    width: 32px; height: 32px;
    display: grid;
    place-items: center;
    border: 1px solid #dde4ef;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    color: #3b4353;
    transition: background .18s;
}
.icon-btn:hover { background: #f2f6fc; }

/* ======================= */
/* VIEWS                   */
/* ======================= */
.view { display: none; }
.view.active { display: block; animation: fadeIn .22s ease; }

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

.view-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ======================= */
/* STATS                   */
/* ======================= */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat {
    background: white;
    border: 1px solid #e6eaf1;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 2px 0 rgba(17,24,39,.03);
}
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #6b7685; }
.stat-value { font-size: 20px; font-weight: 700; margin-top: 2px; }
.stat-primary { border-top: 3px solid #22c55e; }
.stat-success { border-top: 3px solid #10b981; }
.stat-warning { border-top: 3px solid #f59e0b; }
.stat          { border-top: 3px solid #94a3b8; }

/* ======================= */
/* PANEL / TABLE           */
/* ======================= */
.panel {
    background: white;
    border: 1px solid #e6eaf1;
    border-radius: 14px;
    box-shadow: 0 2px 0 rgba(17,24,39,.03);
    margin-bottom: 20px;
    overflow: hidden;
}
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #eef1f6;
    background: linear-gradient(180deg,#ffffff,#fbfcfd);
}
.panel-header h3 { font-size: 15px; font-weight: 600; }
.panel-body { padding: 10px 18px; }
.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 18px;
    border-top: 1px solid #eef1f6;
    background: #fcfdfe;
}

.table-responsive { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
th, td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid #eef1f6;
    white-space: nowrap;
}
th {
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: #6b7685;
    background: #fbfcfd;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f8fafc; }

.progress {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.progress-bar {
    width: 80px;
    height: 6px;
    background: #e6eaf1;
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: #22c55e;
    border-radius: 999px;
}
.progress-text { font-size: 12px; color: #374151; }

/* ======================= */
/* BADGES / CHIPS          */
/* ======================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .3px;
    text-transform: uppercase;
}
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-success { background: #d1fae5; color: #064e3b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    padding: 2px 10px;
    background: #f1f5f9;
    border: 1px solid #e6eaf1;
    border-radius: 999px;
    font-size: 11px;
    color: #334155;
}

/* ======================= */
/* FORMS                   */
/* ======================= */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #334155;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="date"],
.field input[type="datetime-local"],
.field input[type="password"],
.field input[type="search"],
.field select,
.field textarea {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1px solid #dde4ef;
    border-radius: 8px;
    background: white;
    transition: border .18s, box-shadow .18s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,.18);
}
.field-error { display: block; color: #ef4444; font-size: 11px; margin-top: 4px; }
.field.checkbox label {
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ======================= */
/* BUTTONS                 */
/* ======================= */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform .04s ease, background .18s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: #22c55e; color: #06120d; }
.btn-primary:hover { background: #16a34a; }
.btn-secondary { background: #f1f5f9; color: #1f2937; border-color: #dde4ef; }
.btn-secondary:hover { background: #eef2f6; }
.btn-ghost { background: transparent; color: #334155; border-color: #dde4ef; }
.btn-ghost:hover { background: #f8fafc; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link {
    background: transparent;
    color: #2563eb;
    padding: 0;
    border: 0;
}
.btn-link:hover { text-decoration: underline; }

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

.detail-title { font-size: 18px; font-weight: 700; margin-left: 10px; }
.detail-desc { margin: 6px 0 14px; color: #374151; }
.detail-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 16px;
    list-style: none;
    margin: 12px 0 16px;
    font-size: 13px;
    color: #374151;
}
.detail-meta code {
    font-size: 12px;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
}

/* ======================= */
/* CARDS (finished view)   */
/* ======================= */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}
.card {
    background: white;
    border: 1px solid #e6eaf1;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 2px 0 rgba(17,24,39,.03);
    transition: box-shadow .18s, transform .18s;
}
.card:hover {
    box-shadow: 0 8px 28px rgba(17,24,39,.09);
    transform: translateY(-2px);
}
.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.card .card-title {
    font-weight: 700;
    font-size: 14px;
}
.card .card-meta { font-size: 12px; color: #6b7685; margin-top: 6px; }

/* ======================= */
/* TOOLBAR                 */
/* ======================= */
.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.filters { display: flex; gap: 10px; }

.paginator {
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
}

/* ======================= */
/* MODAL                   */
/* ======================= */
.modal[hidden] { display: none; }
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
}
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,.4);
}
.modal-dialog {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    background: white;
    border-radius: 14px;
    border: 1px solid #e6eaf1;
    min-width: 340px;
    max-width: 95vw;
    box-shadow: 0 20px 60px rgba(17,24,39,.12);
    animation: pop .18s ease;
}
@keyframes pop {
    from { opacity: 0; transform: translate(-50%,-46%) scale(.96); }
    to { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #eef1f6;
}
.modal-title { font-weight: 700; }
.modal-body { padding: 16px 18px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 18px 14px;
}

/* ======================= */
/* TOAST                   */
/* ======================= */
.toast-container {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 200;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
}
.toast {
    background: #1f2430;
    color: #f0f4fa;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: 0 8px 30px rgba(17,24,39,.18);
    animation: slideUp .25s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ======================= */
/* EMPTY STATE             */
/* ======================= */
.empty {
    text-align: center;
    padding: 40px 12px;
    color: #6b7685;
}

/* ======================= */
/* RESPONSIVE              */
/* ======================= */
@media (max-width: 960px) {
    #app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 10px 0 40px rgba(0,0,0,.08);
    }
    .sidebar.open { transform: none; }
    .stats-row { grid-template-columns: repeat(2,1fr); }
    .row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr; }
    .topbar { padding: 12px 14px; }
    .views { padding: 14px; }
}
