:root{
    --bg:#f4f7fb;
    --panel:#ffffff;
    --panel-2:#f8fafc;
    --line:#e6ebf2;
    --text:#17202f;
    --muted:#6c7a90;
    --primary:#173a63;
    --primary-2:#224f86;
    --accent:#c6a96b;
    --success:#198754;
    --warning:#f0ad4e;
    --danger:#dc3545;
    --shadow:0 10px 30px rgba(16,24,40,.08);
    --shadow-lg:0 28px 80px rgba(15,36,61,.28);
    --radius:18px;
}

*{
    box-sizing:border-box;
}

html,
body{
    margin:0;
    padding:0;
}

body{
    font-family:Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background:var(--bg);
    color:var(--text);
    font-size:14px;
    line-height:1.5;
}

a{
    text-decoration:none;
    color:inherit;
}

button,
input,
select,
textarea{
    font:inherit;
}

/* =========================
   APP LAYOUT
========================= */

.app-shell{
    display:flex;
    min-height:100vh;
}

.sidebar{
    width:270px;
    background:linear-gradient(180deg,#173a63 0%, #112944 100%);
    color:#fff;
    padding:22px 18px;
    box-shadow:var(--shadow);
    flex-shrink:0;
}

.brand{
    display:flex;
    align-items:center;
    gap:14px;
    padding:8px 8px 22px;
    border-bottom:1px solid rgba(255,255,255,.12);
    margin-bottom:18px;
}

.brand-logo{
    width:46px;
    height:46px;
    border-radius:14px;
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(135deg,var(--accent),#f0e2b7);
    color:#173a63;
    font-weight:800;
    box-shadow:0 8px 20px rgba(0,0,0,.15);
}

.brand-title{
    font-size:18px;
    font-weight:800;
}

.brand-subtitle{
    font-size:12px;
    opacity:.8;
}

.nav-menu{
    display:flex;
    flex-direction:column;
    gap:8px;
}

.nav-link,
.nav-group-toggle{
    width:100%;
    border:0;
    cursor:pointer;
    display:flex;
    align-items:center;
    gap:12px;
    padding:12px 14px;
    border-radius:14px;
    background:transparent;
    color:#eaf1fb;
    text-align:left;
    transition:.2s ease;
}

.nav-link:hover,
.nav-group-toggle:hover{
    background:rgba(255,255,255,.10);
}

.nav-link.active,
.nav-group-toggle.active{
    background:rgba(255,255,255,.16);
    color:#fff;
    font-weight:600;
}

.nav-link.danger{
    margin-top:10px;
    color:#ffd0d5;
}

.nav-group .caret{
    margin-left:auto;
    font-size:12px;
    opacity:.8;
}

.nav-submenu{
    display:none;
    margin:8px 0 6px 8px;
    padding-left:10px;
    border-left:1px solid rgba(255,255,255,.16);
}

.nav-submenu.open{
    display:block;
}

.nav-submenu a{
    display:block;
    padding:10px 12px;
    border-radius:12px;
    color:#d8e4f5;
    margin:3px 0;
}

.nav-submenu a:hover{
    background:rgba(255,255,255,.08);
}

.nav-submenu a.active{
    background:rgba(255,255,255,.14);
    color:#fff;
    font-weight:600;
}

.main-area{
    flex:1;
    min-width:0;
    display:flex;
    flex-direction:column;
}

.topbar{
    position:sticky;
    top:0;
    z-index:10;
    background:rgba(244,247,251,.92);
    backdrop-filter:blur(12px);
    border-bottom:1px solid var(--line);
    padding:20px 28px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:18px;
}

.page-title{
    font-size:24px;
    font-weight:800;
    color:#122033;
}

.page-subtitle{
    color:var(--muted);
    font-size:13px;
    margin-top:4px;
}

.topbar-right{
    display:flex;
    align-items:center;
    gap:12px;
    flex-wrap:wrap;
}

.pill{
    background:#fff;
    border:1px solid var(--line);
    padding:9px 14px;
    border-radius:999px;
    font-weight:600;
    color:#1f3450;
}

.pill.soft{
    background:#edf4fb;
    border-color:#d7e6f6;
}

.user-box{
    display:flex;
    align-items:center;
    gap:10px;
    background:#fff;
    padding:8px 12px;
    border:1px solid var(--line);
    border-radius:999px;
}

.avatar{
    width:38px;
    height:38px;
    border-radius:50%;
    background:linear-gradient(135deg,var(--primary),var(--primary-2));
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
}

.user-name{
    font-weight:700;
    line-height:1.1;
}

.user-role{
    color:var(--muted);
    font-size:12px;
}

.content-area{
    padding:28px;
}

/* =========================
   CARD / SECTION
========================= */

.card,
form.card{
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:var(--radius);
    padding:20px;
    box-shadow:var(--shadow);
    margin-bottom:18px;
}

.section-title{
    font-size:18px;
    font-weight:800;
    margin:0 0 16px;
}

.section-subtitle{
    color:var(--muted);
    margin:-6px 0 16px;
}

.muted{
    color:var(--muted);
    font-size:12px;
}

/* =========================
   GRID
========================= */

.grid{
    display:grid;
    grid-template-columns:repeat(3, minmax(0,1fr));
    gap:18px;
}

.grid-2{
    display:grid;
    grid-template-columns:repeat(2, minmax(0,1fr));
    gap:18px;
}

.grid-4{
    display:grid;
    grid-template-columns:repeat(4, minmax(0,1fr));
    gap:18px;
}

/* =========================
   FORM
========================= */

label{
    display:block;
    font-weight:700;
    margin-bottom:8px;
    color:#23334d;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="file"],
input[type="password"],
input[type="email"],
select,
textarea,
.form-control,
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]){
    width:100%;
    min-height:46px;
    border:1px solid #d7dfeb;
    background:#fff;
    border-radius:12px;
    padding:11px 14px;
    outline:none;
    transition:.2s ease;
}

textarea{
    min-height:110px;
    resize:vertical;
}

input:focus,
select:focus,
textarea:focus,
.form-control:focus{
    border-color:#7aa7d8;
    box-shadow:0 0 0 4px rgba(34,79,134,.10);
}

/* =========================
   BUTTON
========================= */

button,
.btn{
    border:none;
    min-height:44px;
    padding:11px 18px;
    border-radius:12px;
    background:linear-gradient(135deg,var(--primary),var(--primary-2));
    color:#fff;
    font-weight:700;
    cursor:pointer;
    transition:.2s ease;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:8px;
}

button:hover,
.btn:hover{
    transform:translateY(-1px);
    box-shadow:0 10px 22px rgba(23,58,99,.18);
}

.btn-secondary{
    background:#eef3f9;
    color:#173a63;
    border:1px solid #d7e2ef;
}

.btn-danger{
    background:linear-gradient(135deg,#c83349,#dc3545);
}

.btn-sm{
    min-height:34px;
    padding:8px 11px;
    border-radius:10px;
    font-size:12px;
}

/* =========================
   TABLE
========================= */

.table-wrap{
    overflow:auto;
    background:#fff;
    border:1px solid var(--line);
    border-radius:18px;
    box-shadow:var(--shadow);
}

table{
    width:100%;
    border-collapse:separate;
    border-spacing:0;
    min-width:900px;
}

table th{
    background:#eef4fb;
    color:#173a63;
    text-align:left;
    font-size:13px;
    font-weight:800;
    padding:14px 14px;
    border-bottom:1px solid var(--line);
    position:sticky;
    top:0;
}

table td{
    padding:13px 14px;
    border-bottom:1px solid #eef2f7;
    vertical-align:top;
}

table tr:hover td{
    background:#fafcff;
}

.table-actions{
    display:flex;
    align-items:center;
    gap:8px;
    flex-wrap:wrap;
}

.thumbnail{
    width:54px;
    height:54px;
    border-radius:12px;
    object-fit:cover;
    border:1px solid #e6ebf2;
    background:#f8fafc;
}

/* =========================
   ALERT / BADGE
========================= */

.msg{
    background:#edf8f1;
    border:1px solid #d3ebda;
    color:#146c43;
    padding:14px 16px;
    border-radius:14px;
    margin-bottom:18px;
    font-weight:600;
}

.alert-danger{
    background:#fff1f2;
    border:1px solid #ffd5da;
    color:#a61d2d;
}

.alert-warning{
    background:#fff7ea;
    border:1px solid #ffe3b0;
    color:#9a6700;
}

.alert-info{
    background:#eef6ff;
    border:1px solid #d5e7ff;
    color:#194b8d;
}

.badge{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    padding:6px 10px;
    border-radius:999px;
    font-size:12px;
    font-weight:700;
    white-space:nowrap;
}

.badge-success{
    background:#e9f8ef;
    color:#177245;
}

.badge-warning{
    background:#fff3dd;
    color:#9a6a00;
}

.badge-danger{
    background:#ffebee;
    color:#b3261e;
}

.badge-info{
    background:#e8f1ff;
    color:#1f5fbf;
}

.badge-dark{
    background:#ecedf0;
    color:#263445;
}

.link-btn{
    color:#224f86;
    font-weight:700;
}

/* =========================
   DASHBOARD
========================= */

.stats{
    display:grid;
    grid-template-columns:repeat(4, minmax(0,1fr));
    gap:18px;
    margin-bottom:18px;
}

.stat-card{
    background:#fff;
    border:1px solid var(--line);
    border-radius:18px;
    padding:18px;
    box-shadow:var(--shadow);
}

.stat-label{
    color:var(--muted);
    font-weight:600;
    margin-bottom:8px;
}

.stat-value{
    font-size:28px;
    font-weight:800;
    color:#122033;
}

.stat-foot{
    margin-top:8px;
    color:#58708f;
    font-size:12px;
}

.filter-bar{
    display:grid;
    grid-template-columns:2fr 1fr 1fr 1fr auto;
    gap:14px;
    align-items:end;
}

.mini-list{
    display:flex;
    flex-direction:column;
    gap:12px;
}

.mini-list-item{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:14px;
    padding:14px 16px;
    background:#f8fafc;
    border:1px solid #e6ebf2;
    border-radius:14px;
}

.mini-list-item strong{
    color:#122033;
}

/* =========================
   LOGIN PAGE
========================= */

.login-page{
    min-height:100vh;
    margin:0;
    background:
        radial-gradient(circle at top left, rgba(198,169,107,.28), transparent 34%),
        linear-gradient(135deg,#0f243d 0%, #173a63 48%, #f4f7fb 48%, #f4f7fb 100%);
    display:block;
}

.login-wrapper{
    min-height:100vh;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:28px;
}

.login-card{
    width:100%;
    max-width:440px;
    background:#ffffff;
    border-radius:26px;
    padding:32px;
    box-shadow:var(--shadow-lg);
    border:1px solid rgba(255,255,255,.75);
}

.login-brand{
    display:flex;
    align-items:center;
    gap:16px;
    margin-bottom:28px;
}

.login-logo{
    width:62px;
    height:62px;
    border-radius:20px;
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(135deg,#173a63,#224f86);
    color:#ffffff;
    font-weight:800;
    font-size:21px;
    box-shadow:0 12px 28px rgba(23,58,99,.26);
    flex-shrink:0;
}

.login-brand h1{
    margin:0;
    font-size:26px;
    color:#122033;
    font-weight:800;
}

.login-brand p{
    margin:6px 0 0;
    color:#6c7a90;
    font-size:13px;
    line-height:1.5;
}

.login-form{
    margin-top:8px;
}

.form-group{
    margin-bottom:16px;
}

.login-form label{
    display:block;
    font-weight:700;
    color:#23334d;
    margin-bottom:8px;
}

.login-form input{
    width:100%;
    min-height:48px;
    border:1px solid #d7dfeb;
    background:#fff;
    border-radius:14px;
    padding:12px 14px;
    outline:none;
    transition:.2s ease;
}

.login-form input:focus{
    border-color:#7aa7d8;
    box-shadow:0 0 0 4px rgba(34,79,134,.10);
}

.login-button{
    width:100%;
    min-height:48px;
    border:0;
    border-radius:14px;
    background:linear-gradient(135deg,#173a63,#224f86);
    color:#fff;
    font-weight:800;
    cursor:pointer;
    margin-top:4px;
}

.login-demo{
    margin-top:22px;
    padding:15px;
    background:#f8fafc;
    border:1px solid #e6ebf2;
    border-radius:16px;
    color:#6c7a90;
    font-size:12px;
    line-height:1.6;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width:1100px){
    .grid,
    .grid-2,
    .grid-4,
    .stats,
    .filter-bar{
        grid-template-columns:1fr 1fr;
    }
}

@media (max-width:860px){
    .app-shell{
        flex-direction:column;
    }

    .sidebar{
        width:100%;
        border-radius:0;
    }

    .topbar{
        padding:18px;
        flex-direction:column;
        align-items:flex-start;
    }

    .content-area{
        padding:18px;
    }

    .grid,
    .grid-2,
    .grid-4,
    .stats,
    .filter-bar{
        grid-template-columns:1fr;
    }
}

@media (max-width:640px){
    .login-wrapper{
        padding:18px;
    }

    .login-card{
        padding:24px;
        border-radius:22px;
    }

    .login-brand{
        align-items:flex-start;
    }

    .login-brand h1{
        font-size:22px;
    }
}