/* =====================
   COLOR PALETTE
   ===================== */
:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --danger: #b42318;
    --success: #167647;
    --warning: #a15c07;
    --muted: #667789;
    --line: #d9e2e8;
    --bg: #f4f7f9;
    --ink: #14212b;
    color-scheme: light;
}

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

body {
    margin: 0;
    background-color: var(--bg);
    color: var(--ink);
}

a {
    color: var(--primary-dark);
}

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

/* =====================
   SKIP LINK
   ===================== */
.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1000;
    transform: translateY(-140%);
    background: var(--ink);
    color: #fff;
    padding: 10px 14px;
    border-radius: 6px;
    text-decoration: none;
}
.skip-link:focus {
    transform: translateY(0);
}

/* =====================
   APP SHELL & SIDEBAR
   ===================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: #10272c;
    color: #f7fbfb;
    padding: 1.25rem .875rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    gap: .75rem;
    align-items: center;
    padding: .5rem .5rem 1.125rem;
}

.sidebar-brand span {
    display: block;
    color: #b7cbcb;
    font-size: .8125rem;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: .5rem;
    background: #f4c430;
    color: #172033;
    font-weight: 800;
    flex-shrink: 0;
}

.side-nav {
    display: grid;
    gap: .25rem;
}

.side-nav a {
    color: #d7e5e5;
    text-decoration: none;
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: .625rem .75rem;
    border-radius: .5rem;
}

.side-nav a:hover,
.side-nav a.active {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.main-shell {
    flex: 1;
    min-width: 0;
}

/* =====================
   TOPBAR
   ===================== */
.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .875rem 1.5rem;
    background: rgba(255, 255, 255, .95);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
}

.topbar h1 {
    font-size: 1.25rem;
    line-height: 1.2;
    margin: 0;
}

.topbar span {
    color: var(--muted);
    font-size: .8125rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: .625rem;
}

.content {
    padding: 1.5rem;
    max-width: 1440px;
}

/* =====================
   GRID LAYOUTS
   ===================== */
.grid {
    display: grid;
    gap: 1rem;
}
.grid.two   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four  { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* =====================
   PANELS  (Bootstrap card look)
   ===================== */
.panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: .5rem;
    box-shadow: 0 .0625rem .25rem rgba(20, 33, 43, .06);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .75rem;
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--line);
    background-color: #f8f9fa;
    border-radius: .5rem .5rem 0 0;
}

.panel-header h2,
.panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.panel-header p {
    margin: .125rem 0 0;
    color: var(--muted);
    font-size: .8125rem;
    margin-bottom: 0;
}

.panel-body {
    padding: 1rem;
}

/* =====================
   METRIC CARDS
   ===================== */
.metric {
    padding: 1.125rem 1rem;
    min-height: 110px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: .8125rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.metric strong {
    display: block;
    margin-top: .5rem;
    font-size: clamp(1.375rem, 3vw, 1.875rem);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

/* =====================
   BUTTONS  (Bootstrap btn look)
   ===================== */
.button,
button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .4375rem .875rem;
    font-size: .9375rem;
    font-weight: 500;
    line-height: 1.5;
    color: #fff;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background-color: var(--primary);
    border: 1px solid var(--primary);
    border-radius: .375rem;
    transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s;
    white-space: nowrap;
}

.button:hover,
button.button:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.button:focus-visible,
button.button:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 .25rem rgba(15, 118, 110, .3);
}

.button.secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: #fff;
}
.button.secondary:hover {
    background-color: #5c636a;
    border-color: #565e64;
}

.button.danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}
.button.danger:hover {
    background-color: #bb2d3b;
    border-color: #b02a37;
}

.button.small {
    padding: .25rem .625rem;
    font-size: .8125rem;
    border-radius: .25rem;
}

.icon-button {
    border: 1px solid var(--line);
    background: #fff;
    min-width: 40px;
    min-height: 40px;
    border-radius: .375rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* =====================
   TOOLBAR
   ===================== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem;
    margin-bottom: 1rem;
}
.toolbar .field {
    min-width: 160px;
}

/* =====================
   FORMS  (Bootstrap form-control look)
   ===================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .875rem;
}

.field {
    display: grid;
    gap: .25rem;
    align-content: start;
}

.field.full {
    grid-column: 1 / -1;
}

.field label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--ink);
    margin-bottom: .125rem;
}

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

input:not([type=checkbox]):not([type=radio]):not([type=file]),
select,
textarea {
    display: block;
    width: 100%;
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--ink);
    appearance: none;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: .375rem;
    transition: border-color .15s, box-shadow .15s;
}

input:not([type=checkbox]):not([type=radio]):not([type=file]):focus,
select:focus,
textarea:focus {
    color: var(--ink);
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 .25rem rgba(13, 110, 253, .2);
}

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

/* =====================
   TABLES  (Bootstrap table look)
   ===================== */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    margin-bottom: 0;
    color: var(--ink);
    vertical-align: top;
    border-collapse: collapse;
}

th,
td {
    padding: .625rem .75rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

th {
    font-size: .8125rem;
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}

tbody tr:hover {
    background-color: rgba(0, 0, 0, .02);
}

tbody tr:last-child td {
    border-bottom: 0;
}

td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* =====================
   ACTIONS
   ===================== */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
    align-items: center;
}

/* =====================
   BADGES  (Bootstrap badge look)
   ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .25em .5em;
    font-size: .75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .375rem;
}

.badge-success { background-color: #198754; color: #fff; }
.badge-warning { background-color: #ffc107; color: #000; }
.badge-danger  { background-color: #dc3545; color: #fff; }
.badge-neutral { background-color: #6c757d; color: #fff; }

/* =====================
   ALERTS  (Bootstrap alert look)
   ===================== */
.alert {
    position: relative;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: .375rem;
}

.alert-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
}

.alert-danger {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

.alert-warning {
    color: #664d03;
    background-color: #fff3cd;
    border-color: #ffecb5;
}

.alert-info {
    color: #055160;
    background-color: #cff4fc;
    border-color: #b6effb;
}

/* =====================
   TABS  (Bootstrap nav-pills look)
   ===================== */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .375rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: .5rem;
}

.tabs a {
    display: inline-flex;
    align-items: center;
    padding: .375rem .75rem;
    font-size: .875rem;
    color: var(--muted);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: .375rem;
    transition: color .15s, background-color .15s;
}

.tabs a:hover {
    color: var(--primary);
    background-color: rgba(15, 118, 110, .06);
}

.tabs a.active {
    color: #fff;
    background-color: var(--primary);
    border-color: var(--primary);
    font-weight: 500;
}

/* =====================
   EMPTY STATE
   ===================== */
.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--muted);
    font-style: italic;
}

/* =====================
   AUTH PAGES
   ===================== */
.auth-body {
    background: linear-gradient(135deg, #eef6f5 0%, #f7f0e7 100%);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.auth-panel {
    width: min(440px, 100%);
    background: rgba(255, 255, 255, .97);
    border: 1px solid var(--line);
    border-radius: .5rem;
    box-shadow: 0 .25rem 1rem rgba(0, 0, 0, .1);
    padding: 2rem 1.75rem;
}

.auth-panel h1 {
    margin: 1rem 0 .25rem;
    font-size: 1.75rem;
}

.auth-panel p {
    margin-top: 0;
    color: var(--muted);
}

.auth-panel .grid {
    display: grid;
    gap: 1rem;
}

/* =====================
   SPACING UTILITIES
   ===================== */
.mt-16 { margin-top: 1rem; }
.mb-16 { margin-bottom: 1rem; }

/* =====================
   RESPONSIVE
   ===================== */
.hide-desktop { display: none; }

@media (max-width: 960px) {
    .app-shell { display: block; }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 280px;
        z-index: 100;
        transform: translateX(-104%);
        transition: transform 180ms ease-out;
    }

    .sidebar.open { transform: translateX(0); }
    .hide-desktop { display: inline-flex; }
    .topbar { padding: .75rem 1rem; }
    .content { padding: 1rem; }

    .grid.two,
    .grid.three,
    .grid.four,
    .form-grid { grid-template-columns: 1fr; }

    .user-menu span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}
