/* =========================================================================
   Innkeeper Gateway Portal — enterprise theme aligned to the MyBSF design
   system: white app bar, quiet gray sidebar, cool gray canvas, white cards
   with hairline borders, teal primary actions, Roboto type.
   ========================================================================= */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --sidebar-bg: #f7f8fa;
    --border: #e4e7ea;
    --border-strong: #cfd6dc;
    --text: #202a33;
    --text-2: #6b7684;
    --text-3: #98a2ae;
    --teal: #1d7a8b;
    --teal-dark: #14606f;
    --teal-tint: #e3f0f3;
    --link: #3d9bc2;
    --green: #2e7d32;
    --green-tint: #e6f4e7;
    --red: #c0392b;
    --red-tint: #fcebe8;
    --amber-tint: #fdf3d7;
    --amber-text: #7a5b00;
    --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-2: 0 4px 12px rgba(16, 24, 40, 0.08);
    --radius: 8px;
    --topbar-h: 60px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "Roboto", "Segoe UI", "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

h1,
h2 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.01em;
}

a {
    color: var(--link);
}

.hidden {
    display: none !important;
}

.muted {
    color: var(--text-2);
}

/* ------------------------------- Top bar -------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem 0 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background-color 140ms ease;
}

.icon-button:hover {
    background: var(--bg);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: var(--teal);
    color: #fff;
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 400;
    letter-spacing: -0.01em;
}

.brand-name strong {
    font-weight: 700;
}

.env-chip {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--amber-text);
    background: var(--amber-tint);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.3rem 0.6rem 0.3rem 0.35rem;
    border-radius: 999px;
    background: #eaf4f7;
    color: var(--text-2);
    cursor: default;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--teal);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.user-meta strong {
    font-size: 0.82rem;
    color: var(--text);
    font-weight: 500;
}

.user-meta small {
    font-size: 0.7rem;
    color: var(--text-3);
}

/* -------------------------------- Layout -------------------------------- */

.shell {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr);
    min-height: calc(100vh - var(--topbar-h));
}

body.nav-collapsed .shell {
    grid-template-columns: minmax(0, 1fr);
}

body.nav-collapsed .sidebar {
    display: none;
}

.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 1rem 0.6rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1.5rem;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.9rem;
    border-radius: 999px;
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background-color 140ms ease, color 140ms ease;
}

.nav-link svg {
    flex: none;
    opacity: 0.75;
}

.nav-link:hover {
    background: rgba(29, 122, 139, 0.07);
    color: var(--text);
}

.nav-link.active {
    background: var(--teal-tint);
    color: var(--teal-dark);
}

.nav-link.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 0 0.9rem 0.5rem;
    color: var(--text-3);
    font-size: 0.72rem;
    line-height: 1.45;
}

.content {
    padding: 1.75rem 2rem 2.5rem;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* --------------------------------- Pages -------------------------------- */

.page {
    display: grid;
    gap: 1.25rem;
    animation: page-in 220ms ease both;
}

@keyframes page-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.page-head h1 {
    font-size: 1.7rem;
}

.page-sub {
    margin: 0.35rem 0 0;
    color: var(--text-2);
    max-width: 62ch;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    white-space: nowrap;
    padding-top: 0.4rem;
}

/* --------------------------------- Cards -------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 1.35rem 1.5rem;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.85rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-head h2 {
    font-size: 1.05rem;
    font-weight: 500;
}

/* --------------------------------- Stats -------------------------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-label {
    color: var(--text-2);
    font-size: 0.8rem;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.stat-value.sm {
    font-size: 1.15rem;
}

.stat-sub {
    color: var(--text-3);
    font-size: 0.72rem;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.kv-grid > div {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

/* --------------------------------- Chips --------------------------------- */

.chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.18rem 0.7rem;
    font-size: 0.74rem;
    font-weight: 500;
    background: #eef1f4;
    color: var(--text-2);
    white-space: nowrap;
}

.chip.neutral {
    background: #eef1f4;
    color: var(--text-2);
}

.chip-amber {
    background: var(--amber-tint);
    color: var(--amber-text);
}

/* ------------------------------ Throughput ------------------------------- */

.bar-wrap {
    display: flex;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: #edf0f3;
}

.bar {
    height: 100%;
    transition: width 400ms ease;
}

.bar.success {
    background: var(--teal);
}

.bar.fail {
    background: #e57373;
}

/* -------------------------------- Tables --------------------------------- */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

th {
    text-align: left;
    font-weight: 500;
    color: var(--text-2);
    font-size: 0.78rem;
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap;
}

td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: top;
}

tbody tr:hover td {
    background: #fafbfc;
}

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

.empty-cell {
    color: var(--text-3);
    text-align: center;
    padding: 1.4rem 1rem;
}

.status-ok {
    color: var(--green);
    font-weight: 500;
}

.status-fail {
    color: var(--red);
    font-weight: 500;
}

/* -------------------------------- Buttons -------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border-radius: 999px;
    padding: 0.55rem 1.35rem;
    font-family: inherit;
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.btn-primary {
    border: 1px solid var(--teal);
    background: var(--teal);
    color: #fff;
}

.btn-primary:hover {
    background: var(--teal-dark);
    border-color: var(--teal-dark);
}

.btn-outline {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--teal-dark);
}

.btn-outline:hover {
    border-color: var(--teal);
    background: #f4fafb;
}

/* --------------------------------- Forms --------------------------------- */

.form-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 0.25rem 0 0.75rem;
}

.form-row label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field-label {
    font-size: 0.78rem;
    color: var(--text-2);
}

.form-row input[type="date"],
.form-row input[type="file"] {
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    background: var(--surface);
    font-family: inherit;
    font-size: 0.86rem;
    color: var(--text);
    min-width: 220px;
}

.form-row input:focus-visible {
    outline: 2px solid var(--teal-tint);
    border-color: var(--teal);
}

.info-note {
    margin-top: 0.75rem;
    padding: 0.8rem 1rem;
    border-left: 3px solid var(--teal);
    border-radius: 4px;
    background: #f2f8fa;
    color: var(--text-2);
    font-size: 0.82rem;
    line-height: 1.55;
}

/* ------------------------------ Error banner ------------------------------ */

.error {
    margin: 0;
    padding: 0.8rem 1rem;
    border-left: 3px solid var(--red);
    border-radius: 4px;
    background: var(--red-tint);
    color: #7f2318;
    font-size: 0.85rem;
}

/* --------------------------------- Footer --------------------------------- */

.content-footer {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    color: var(--text-3);
    font-size: 0.76rem;
    text-align: center;
}

/* ------------------------------- Responsive ------------------------------- */

@media (max-width: 1080px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        flex-direction: row;
        align-items: center;
        border-right: 0;
        border-bottom: 1px solid var(--border);
        padding: 0.5rem 0.75rem;
        overflow-x: auto;
    }

    .sidebar nav {
        flex-direction: row;
    }

    .sidebar-footer {
        display: none;
    }

    .user-meta {
        display: none;
    }

    .content {
        padding: 1.25rem 1rem 2rem;
    }

    .page-head {
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .stat-grid,
    .kv-grid {
        grid-template-columns: 1fr;
    }
}
