/* GateFlow Central - App Shell */
:root {
    --bg: #eef1f5;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --border: #dbe2ea;
    --text: #1f2a37;
    --muted: #5d6b7d;
    --primary: #125b87;
    --primary-strong: #0e4768;
    --danger: #c0392b;
    --success: #1f8f53;
    --radius: 12px;
    --shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
    --sidebar-width: 260px;
    --font-sans: "Segoe UI", "Inter", "Noto Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: var(--font-sans); font-size: 16px; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 1rem; color: #1f2a37; }
h1 { font-size: clamp(1.9rem, 2vw, 2.4rem); }
p { margin: 0 0 1rem; color: var(--text); }

.app-shell { min-height: 100vh; display: flex; }
.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0e4768 0%, #11537a 100%);
    color: #fff;
    padding: 1.2rem 0.95rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}
.app-brand-wrap { padding: 0 0.5rem 0.8rem; }
.app-logo { color: #fff; font-weight: 800; font-size: 1.45rem; letter-spacing: 0.2px; }
.app-logo:hover { text-decoration: none; }
.app-user-card {
    margin: 0.4rem 0.5rem 1rem;
    padding: 0.7rem 0.8rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
}
.app-user-label { display: block; font-size: 0.75rem; opacity: 0.84; text-transform: uppercase; letter-spacing: 0.08em; }
.app-user-name { display: block; margin-top: 0.2rem; font-size: 0.94rem; word-break: break-word; }

.app-nav { display: flex; flex-direction: column; gap: 0.35rem; padding: 0 0.35rem; overflow-y: auto; overflow-x: hidden; }
.app-nav-group { margin-bottom: 0.65rem; }
.app-nav-group a { display: block; width: 100%; }
.app-nav-group-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.76);
    padding: 0.35rem 0.72rem 0.2rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.app-nav-group-icon { font-size: 0.68rem; opacity: 0.9; }
.app-nav a {
    color: rgba(255, 255, 255, 0.92);
    padding: 0.58rem 0.72rem;
    border-radius: 8px;
    font-weight: 600;
    transition: background-color 0.15s ease;
    white-space: nowrap;
}
.app-nav a:hover { background: rgba(255, 255, 255, 0.13); text-decoration: none; }
.app-nav a.is-active { background: rgba(255, 255, 255, 0.22); color: #fff; }
.app-nav-planned {
    display: block;
    color: rgba(255, 255, 255, 0.6);
    padding: 0.54rem 0.72rem;
    border-radius: 8px;
    font-size: 0.92rem;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.app-logout {
    margin: 0.9rem 0.5rem 0;
    padding: 0.62rem 0.72rem;
    border-radius: 8px;
    font-weight: 700;
    color: #fff;
    background: rgba(0, 0, 0, 0.22);
    text-align: center;
}
.app-logout:hover { background: rgba(0, 0, 0, 0.34); text-decoration: none; }

.app-workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    display: none;
    align-items: center;
    gap: 0.8rem;
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.9rem;
    position: sticky;
    top: 0;
    z-index: 40;
}
.app-nav-toggle {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
    cursor: pointer;
}
.app-logo-mobile { font-size: 1.2rem; color: var(--primary); }
.app-user-mobile { margin-left: auto; font-size: 0.85rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }

.app-main { flex: 1; padding: 1.45rem 1.5rem; }
.page-content { max-width: 1220px; }
.page-header { max-width: 1220px; margin-bottom: 1rem; }
.breadcrumb {
    list-style: none;
    padding: 0;
    margin: 0 0 0.4rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.87rem;
    color: var(--muted);
}
.breadcrumb li { display: inline-flex; align-items: center; gap: 0.4rem; }
.breadcrumb li + li::before { content: "/"; color: #8c98a8; margin-right: 0.1rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.page-title { margin: 0; font-size: clamp(1.4rem, 1.5vw, 1.8rem); color: #203247; }
.page-content > h1:first-child { display: none; }
.app-footer { border-top: 1px solid var(--border); background: #fff; padding: 0.7rem 1.5rem; color: var(--muted); font-size: 0.9rem; }
.app-footer-inner { max-width: 1220px; }
.app-backdrop { display: none; }

.alert { padding: 0.75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid transparent; }
.alert-success { background: #ddf6e7; color: #0f6a3c; border-color: #bdeacd; }
.alert-error { background: #fbe6e6; color: #8d2424; border-color: #f1c5c5; }

.btn { display: inline-block; padding: 0.58rem 1rem; border-radius: 9px; border: none; cursor: pointer; font-size: 1rem; line-height: 1; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); text-decoration: none; }
.btn-secondary { background: #eef2f6; color: var(--text); margin-left: 0.5rem; border: 1px solid var(--border); }
.btn-link { background: none; border: none; cursor: pointer; font-size: inherit; color: var(--primary); padding: 0; }
.btn-link.danger { color: var(--danger); }
.btn-link:hover { text-decoration: underline; }

.inline-form { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.form label { display: block; margin-top: 0.8rem; font-weight: 600; color: #2a3748; }
.form input[type="text"], .form input[type="email"], .form input[type="password"], .form select {
    width: 100%;
    max-width: 460px;
    padding: 0.6rem 0.65rem;
    margin-top: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
}
.form input:focus, .form select:focus { outline: 2px solid rgba(18, 91, 135, 0.2); border-color: var(--primary); }
.form button { margin-top: 1rem; }
.form .checkbox-group { margin: 0.5rem 0; }
.form .checkbox-group label { display: inline-block; margin-right: 1rem; font-weight: normal; }
.form-note { color: var(--muted); font-size: 0.875rem; margin-top: 0.45rem; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.data-table th, .data-table td { padding: 0.78rem 0.95rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { background: var(--surface-soft); font-weight: 700; color: #2a3748; }
.data-table tr:last-child td { border-bottom: none; }
.data-table a { margin-right: 0.75rem; }
.data-table form { display: inline; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1.2rem;
}
.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
}
.metric-card .metric-label { color: var(--muted); font-size: 0.9rem; margin-bottom: 0.3rem; }
.metric-card .metric-value { font-size: 1.7rem; font-weight: 800; color: var(--text); }
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    margin-bottom: 1rem;
}
.panel h2 { font-size: 1.2rem; margin-bottom: 0.7rem; }
.status-list { margin: 0; padding-left: 1.1rem; }
.status-list li { margin: 0.35rem 0; color: #2a3748; }
.status-missing { color: #854d0e; }
.status-missing strong { color: #7a2e1a; }

/* Login page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at top, #f7fbff, #ecf1f6 45%); }
.login-box { background: var(--surface); padding: 2rem; border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 390px; border: 1px solid var(--border); }
.login-box h1 { margin: 0 0 0.25rem; font-size: 1.7rem; }
.login-subtitle { color: var(--muted); font-size: 0.95rem; margin-bottom: 1.4rem; }
.login-form label { display: block; margin-top: 0.75rem; font-weight: 600; }
.login-form input { width: 100%; padding: 0.62rem; margin-top: 0.25rem; border: 1px solid var(--border); border-radius: 9px; }
.login-form button { width: 100%; margin-top: 1.2rem; padding: 0.68rem; background: var(--primary); color: #fff; border: none; border-radius: 9px; font-size: 1rem; cursor: pointer; }
.login-form button:hover { background: var(--primary-strong); }

@media (max-width: 1024px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        width: min(86vw, var(--sidebar-width));
    }
    .app-layout.nav-open .app-sidebar { transform: translateX(0); }
    .app-layout.nav-open .app-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(8, 16, 29, 0.38);
        z-index: 50;
    }
    .app-topbar { display: flex; }
    .app-main { padding: 1rem; }
    .app-footer { padding: 0.7rem 1rem; }
    .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    body { font-size: 15px; }
    .app-main { padding: 0.85rem; }
    .page-header { margin-bottom: 0.75rem; }
    .breadcrumb { font-size: 0.8rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    h1 { font-size: 1.8rem; }
    .data-table { border: none; box-shadow: none; background: transparent; }
    .data-table thead { display: none; }
    .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
    .data-table tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 10px;
        box-shadow: var(--shadow);
        margin-bottom: 0.75rem;
        padding: 0.15rem 0;
    }
    .data-table td {
        border: 0;
        border-bottom: 1px dashed #e5ebf2;
        padding: 0.6rem 0.9rem;
        min-height: 2.1rem;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.9rem;
        text-align: right;
    }
    .data-table td:last-child { border-bottom: 0; }
    .data-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #304257;
        text-align: left;
        flex: 1;
        max-width: 46%;
    }
    .data-table td > * { text-align: right; }
    .data-table td form { margin-left: auto; }
}
