:root {
    color-scheme: light;
    --primary: #153b66;
    --primary-dark: #102c4d;
    --primary-soft: #eaf1f8;
    --gold: #c9a66b;
    --background: #f4f6f9;
    --surface: #ffffff;
    --text: #1c2938;
    --muted: #708093;
    --border: #e3e8ef;
    --success: #21845a;
    --danger: #c84e50;
    --warning: #b58126;
    --shadow: 0 12px 32px rgba(20, 42, 66, 0.06);
    --radius: 16px;
}

* { box-sizing: border-box; }
html { min-width: 320px; font-size: 16px; }
body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid rgba(41, 117, 184, 0.35); outline-offset: 2px; }

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin: 0 0 1rem;
    border: 1px solid transparent;
}
.alert-success { background: #eaf6ef; border-color: #c8e7d3; color: #176642; }
.alert-danger { background: #fff0f0; border-color: #f2cccc; color: #a6383a; }
.alert-info { background: #edf5fc; border-color: #cfe0ef; color: #214d72; }
.alert-warning { background: #fff8e9; border-color: #f0dfb8; color: #8e681e; }

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    padding: 0.72rem 1.1rem;
    font-weight: 650;
    transition: background-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 5px 12px rgba(21, 59, 102, 0.16);
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 8px 16px rgba(21, 59, 102, 0.2); }
.btn-secondary { background: #fff; border-color: #d8e0e8; color: var(--primary); }
.btn-secondary:hover { background: #f4f7fa; box-shadow: 0 5px 12px rgba(21, 59, 102, 0.08); }
.btn-danger { background: #b94747; color: #fff; }
.btn-danger:hover { background: #9f3636; }
.btn-warning { background: #fff4df; border-color: #f0dfb8; color: #85601e; }
.btn-warning:hover { background: #fcebc9; }
.btn-icon { width: 17px; height: 17px; margin-right: 0.45rem; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-wide { width: 100%; }

.brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 12px;
    background: linear-gradient(145deg, #244e79, #c9a66b);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    letter-spacing: 0.04em;
}
.brand-mark.large { width: 58px; height: 58px; font-size: 1.2rem; margin: 0 auto 1rem; }

.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    background:
        radial-gradient(ellipse at 18% 16%, rgba(201,166,107,0.12), transparent 33%),
        radial-gradient(ellipse at 82% 85%, rgba(21,59,102,0.12), transparent 35%),
        #f3f6f9;
}
.auth-card {
    width: min(100%, 440px);
    background: var(--surface);
    border: 1px solid rgba(227,232,239,0.9);
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(21, 44, 71, 0.12);
    padding: clamp(1.5rem, 5vw, 2.5rem);
}
.auth-header { text-align: center; margin-bottom: 1.75rem; }
.auth-header h1 { margin: 0.25rem 0; color: var(--primary-dark); font-size: 1.6rem; letter-spacing: -0.025em; }
.auth-header p { margin: 0; color: var(--muted); }
.auth-form { display: grid; gap: 1.1rem; }
.auth-form label, .admin-form label { display: grid; gap: 0.45rem; color: #34465a; font-size: 0.92rem; font-weight: 600; }
.auth-form input:not([type="submit"]), .admin-form .form-control {
    width: 100%;
    min-height: 46px;
    border: 1px solid #d8e0e9;
    border-radius: 9px;
    padding: 0.72rem 0.85rem;
    background: #fff;
    color: var(--text);
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.auth-form input::placeholder, .admin-form input::placeholder { color: #9aa7b5; }
.auth-form input:focus, .admin-form .form-control:focus, .select-field:focus, .textarea-field:focus {
    border-color: #7095bb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(41, 117, 184, 0.12);
}
.auth-form .btn { width: 100%; margin-top: 0.3rem; }
.auth-password-field,
.password-form-field { display: grid; gap: 0.45rem; }
.password-form-field > label { display: block; }
.password-input { position: relative; width: 100%; }
.password-input input.form-control { padding-right: 7.2rem; }
.password-toggle {
    position: absolute;
    top: 50%;
    right: 0.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    min-height: 32px;
    padding: 0.25rem 0.42rem;
    transform: translateY(-50%);
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #607286;
    cursor: pointer;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 650;
    white-space: nowrap;
}
.password-toggle:hover { background: rgba(72, 99, 126, 0.08); color: #263f59; }
.password-toggle:focus-visible { outline: 2px solid #7095bb; outline-offset: 2px; }
.password-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.password-eye-slash { display: none; }
.password-toggle.is-visible .password-eye-slash { display: block; }

.admin-shell { display: flex; min-height: 100vh; }
.sidebar {
    position: sticky;
    top: 0;
    width: 248px;
    height: 100vh;
    height: 100dvh;
    flex: 0 0 248px;
    min-height: 0;
    overflow: hidden;
    background: linear-gradient(180deg, #142f4f, #102844);
    color: white;
    padding: 1.4rem 1rem 1rem;
    display: flex;
    flex-direction: column;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.35rem 0.25rem 1.35rem;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 1.35rem;
}
.brand strong { display: block; font-size: 0.96rem; letter-spacing: 0.01em; }
.brand small { display: block; color: rgba(255,255,255,0.64); font-size: 0.75rem; margin-top: 0.08rem; }
.sidebar nav {
    display: grid;
    flex: 1 1 auto;
    min-height: 0;
    gap: 0.3rem;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 0.25rem 0.45rem 0;
    scrollbar-color: rgba(255,255,255,0.32) transparent;
    scrollbar-width: thin;
}
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb { border-radius: 99px; background: rgba(255,255,255,0.26); }
.sidebar nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.42); }
.sidebar nav a {
    display: flex;
    align-items: center;
    min-height: 43px;
    color: rgba(255,255,255,0.76);
    padding: 0.68rem 0.8rem;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: 0.9rem;
    font-weight: 550;
    transition: color 0.16s ease, background-color 0.16s ease;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar nav a[aria-current="page"] {
    color: #fff;
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.09);
    box-shadow: inset 3px 0 0 var(--gold);
}
.sidebar-footer {
    flex: 0 0 auto;
    margin-top: auto;
    padding-top: 0.8rem;
    border-top: 1px solid rgba(255,255,255,0.12);
    background: #102844;
}
.logout-link {
    display: block;
    color: rgba(255,255,255,0.82);
    text-align: left;
    padding: 0.72rem 0.8rem;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,0.12);
    font-size: 0.88rem;
}
.logout-link:hover { background: rgba(255,255,255,0.08); color: white; }
.content { min-width: 0; flex: 1; padding: 2rem clamp(1.25rem, 3vw, 2.7rem); }
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    max-width: 1440px;
    margin: 0 auto 1.75rem;
    padding-bottom: 1.3rem;
    border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; color: var(--primary-dark); font-size: clamp(1.45rem, 2vw, 1.8rem); line-height: 1.2; letter-spacing: -0.035em; }
.page-description { color: var(--muted); margin: 0.28rem 0 0; font-size: 0.88rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.8rem; }
.user-pill {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    background: white;
    color: #334d69;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 650;
    box-shadow: 0 2px 6px rgba(20,42,66,0.03);
}

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card {
    position: relative;
    overflow: hidden;
    min-height: 126px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem 1.25rem;
    border: 1px solid var(--border);
}
.stat-card::after { content: ""; position: absolute; width: 70px; height: 70px; border-radius: 50%; right: -26px; top: -28px; background: var(--primary-soft); }
.stat-card span { position: relative; z-index: 1; color: var(--muted); display: block; margin-bottom: 0.6rem; font-size: 0.85rem; font-weight: 600; }
.stat-card strong { position: relative; z-index: 1; color: var(--primary-dark); font-size: 1.9rem; font-weight: 720; letter-spacing: -0.04em; }
.stat-card.success::after { background: #e7f4ec; }
.stat-card.success strong { color: var(--success); }
.stat-card.danger::after { background: #fbeded; }
.stat-card.danger strong { color: var(--danger); }

.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.panel {
    min-width: 0;
    background: white;
    border-radius: var(--radius);
    padding: 1.2rem 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}
.panel h3 { margin: 0; color: var(--primary-dark); font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
.chart-panel { min-height: 320px; }
.chart-canvas { position: relative; height: 250px; margin-top: 1rem; }
.chart-canvas canvas { width: 100% !important; height: 100% !important; }
.table-panel { overflow: hidden; }
.table-panel table { width: 100%; border-collapse: collapse; margin-top: 0.75rem; }
.table-panel th, .table-panel td {
    padding: 0.82rem 0.75rem;
    border-bottom: 1px solid #edf0f4;
    text-align: left;
    font-size: 0.88rem;
    vertical-align: top;
}
.table-panel th { color: #788697; font-size: 0.76rem; font-weight: 700; letter-spacing: 0.055em; text-transform: uppercase; white-space: nowrap; }
.table-panel tbody tr:last-child td { border-bottom: 0; }
.table-panel tbody tr:hover { background: #fafbfd; }
.table-panel td { color: #384a5e; }
.table-panel td.empty-state { padding: 2rem 1rem; color: var(--muted); text-align: center; }

.customer-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 2.5rem);
    background:
        radial-gradient(ellipse at 12% 10%, rgba(201,166,107,0.12), transparent 33%),
        radial-gradient(ellipse at 90% 90%, rgba(21,59,102,0.1), transparent 37%),
        #f3f6f9;
}
.customer-shell { width: min(100%, 580px); }
.customer-card {
    background: white;
    border-radius: 22px;
    box-shadow: 0 20px 55px rgba(20,42,66,0.1);
    padding: clamp(1.35rem, 5vw, 2.2rem);
    border: 1px solid rgba(227,232,239,0.95);
}
.customer-header { text-align: center; margin-bottom: 1.6rem; }
.customer-header h1 { color: var(--primary-dark); font-size: clamp(1.65rem, 5vw, 2.2rem); margin: 0.9rem 0 0.5rem; line-height: 1.18; letter-spacing: -0.04em; }
.customer-header p { color: var(--muted); margin: 0 auto; max-width: 390px; font-size: 0.95rem; }
.logo-badge {
    background: linear-gradient(145deg, #244e79, #c9a66b);
    width: 62px;
    height: 62px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: white;
    font-weight: 800;
    letter-spacing: 0.04em;
    margin: 0 auto;
    box-shadow: 0 7px 16px rgba(21,59,102,0.15);
}
.branch-info { background: #f2f6fa; border: 1px solid #e2eaf2; border-radius: 10px; padding: 0.78rem 0.9rem; margin-bottom: 0.7rem; color: #50667d; font-size: 0.9rem; }
.branch-info strong { color: var(--primary-dark); }
.customer-form { display: grid; gap: 1.25rem; margin-top: 1.15rem; }
.field-group { display: grid; gap: 0.58rem; }
.question-title { color: #344b63; font-size: 0.8rem; font-weight: 750; line-height: 1.5; letter-spacing: 0.06em; }
.rating-stars { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.6rem; }
.rating-scale { display: flex; justify-content: space-between; color: #8794a3; font-size: 0.72rem; }
.star-option {
    display: grid;
    place-items: center;
    position: relative;
    min-height: 54px;
    border: 1px solid #dce4ec;
    border-radius: 10px;
    background: #fbfcfd;
    text-align: center;
    cursor: pointer;
    font-weight: 700;
    color: #4d6074;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.star-option:hover { border-color: #9bb3ca; transform: translateY(-1px); }
.star-option input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.star-option:has(input:checked) { color: var(--primary-dark); background: #edf3f8; border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }
.star-option:has(input:focus-visible) { outline: 3px solid rgba(41,117,184,0.35); outline-offset: 2px; }
.customer-form label:not(.star-option) { color: #344b63; font-size: 0.85rem; font-weight: 650; }
.select-field, .textarea-field {
    width: 100%;
    min-height: 46px;
    border: 1px solid #d8e0e9;
    border-radius: 9px;
    padding: 0.72rem 0.85rem;
    background: white;
    color: var(--text);
}
.textarea-field { min-height: 118px; resize: vertical; }
.customer-form .btn { min-height: 50px; margin-top: 0.15rem; }
.success-page { background: radial-gradient(ellipse at 50% 20%, rgba(201,166,107,0.12), transparent 34%), #f3f7f4; }
.success-card { text-align: center; padding-block: 2.5rem; }
.success-card h1 { color: var(--primary-dark); margin: 0.2rem 0 0.5rem; }
.success-card p { color: var(--muted); margin: 0 0 1.4rem; }
.success-icon {
    width: 72px; height: 72px; border-radius: 50%; background: #e8f5ed; color: var(--success);
    display: grid; place-items: center; font-size: 2.2rem; font-weight: 700; margin: 0 auto 1rem;
}
.error-panel { text-align: center; }

@media (max-width: 1100px) {
    .sidebar { width: 220px; flex-basis: 220px; }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
    .admin-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; max-height: none; overflow: visible; padding: 0.8rem 1rem; }
    .brand { padding: 0.2rem 0.1rem 0.8rem; margin-bottom: 0.7rem; }
    .sidebar nav { display: flex; flex: 0 0 auto; min-height: auto; gap: 0.4rem; overflow-x: auto; overflow-y: hidden; padding: 0 0 0.3rem; scrollbar-width: none; }
    .sidebar nav::-webkit-scrollbar { display: none; }
    .sidebar nav a { white-space: nowrap; min-height: 38px; padding: 0.55rem 0.7rem; font-size: 0.82rem; }
    .sidebar nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--gold); }
    .sidebar-footer { padding-top: 0.45rem; }
    .logout-link { display: inline-block; padding: 0.48rem 0.75rem; }
    .content { padding: 1.3rem 1rem 2rem; }
    .topbar { margin-bottom: 1.2rem; }
}
@media (max-width: 600px) {
    .stats-grid, .chart-grid { grid-template-columns: 1fr; }
    .stats-grid { gap: 0.7rem; }
    .stat-card { min-height: 105px; padding: 1rem 1.1rem; }
    .chart-panel { min-height: 290px; }
    .chart-canvas { height: 220px; }
    .table-panel { padding: 1rem; }
    .table-panel table { min-width: 570px; }
    .table-panel { overflow-x: auto; }
    .customer-page { padding: 0.8rem; }
    .customer-card { border-radius: 17px; }
    .rating-stars { gap: 0.42rem; }
    .star-option { min-height: 50px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
