:root {
    color-scheme: light;
    --blue: #064f8f;
    --blue-2: #0f6fb5;
    --ink: #172033;
    --muted: #667085;
    --line: #d9e2ec;
    --soft: #eef5fb;
    --green: #1f8a5b;
    --red: #bf3434;
    --orange: #b56b00;
    --yellow: #f4bd24;
    --surface: #ffffff;
    --bg: #f6f8fb;
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: linear-gradient(150deg, #f0f7fc 0%, #ffffff 58%, #fff7df 100%);
}

.login-panel {
    width: min(430px, 100%);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(17, 35, 55, 0.12);
}

.brand-mark {
    width: 72px;
    height: 72px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--blue);
    color: white;
    font-weight: 800;
    letter-spacing: 0;
    margin-bottom: 20px;
}

.brand-mark.compact {
    width: 44px;
    height: 44px;
    margin: 0;
    font-size: 14px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 32px; }
h2 { margin-bottom: 0; font-size: 28px; }
h3 { margin-bottom: 0; font-size: 20px; }
p { color: var(--muted); line-height: 1.5; }

.form-grid { display: grid; gap: 16px; }
label { display: grid; gap: 7px; color: #344054; font-weight: 600; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: white;
    color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }

.primary, .secondary, .ghost, .danger, .warning {
    border: 0;
    border-radius: 8px;
    padding: 11px 14px;
    font-weight: 700;
}
.primary { background: var(--blue); color: white; }
.secondary { background: var(--soft); color: var(--blue); }
.ghost { background: white; color: var(--ink); border: 1px solid var(--line); }
.danger { background: #fff0f0; color: var(--red); border: 1px solid #ffd0d0; }
.warning { background: #fff3cf; color: #734600; border: 1px solid #f4d47a; }
.primary:disabled, .secondary:disabled, .ghost:disabled { opacity: 0.55; cursor: default; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 280px 1fr; }
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #0d2438;
    color: white;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.sidebar-brand { display: flex; gap: 12px; align-items: center; }
.sidebar-brand span { display: block; color: #b8c7d7; font-size: 13px; margin-top: 3px; }
.nav-list { display: grid; gap: 8px; }
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    background: transparent;
    color: #d9e6f2;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 11px 12px;
}
.nav-item.active { background: #173b58; border-color: #2e5f85; color: white; }
.nav-item .nav-icon { width: 22px; text-align: center; }
.logout { margin-top: auto; background: #132f48; color: white; border-color: #2e5f85; }

.content-shell { min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(246, 248, 251, 0.94);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
    padding: 22px 28px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
#eyebrow { display: block; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.user-strip { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.user-strip span, .user-strip strong, .pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 999px;
    padding: 5px 10px;
    background: white;
    border: 1px solid var(--line);
    color: #344054;
    font-size: 13px;
}

.view-host { padding: 28px; display: grid; gap: 22px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    box-shadow: 0 2px 12px rgba(16, 24, 40, 0.04);
}
.group-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.group-panel summary {
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    font-weight: 800;
    list-style: none;
}
.group-panel summary::-webkit-details-marker { display: none; }
.group-panel summary::before {
    content: "›";
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin-right: 2px;
    color: var(--blue);
    transform: rotate(0deg);
    transition: transform 140ms ease;
}
.group-panel[open] summary::before { transform: rotate(90deg); }
.group-panel summary span:first-child {
    margin-right: auto;
}
.group-meta {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-align: right;
}
.group-body {
    border-top: 1px solid var(--line);
    padding: 12px;
    display: grid;
    gap: 12px;
    background: #fbfdff;
}
.module-button {
    min-height: 108px;
    text-align: left;
    background: white;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    display: grid;
    gap: 8px;
}
.module-button:hover { border-color: var(--blue-2); box-shadow: 0 8px 28px rgba(6, 79, 143, 0.1); }
.module-button strong { font-size: 18px; }
.module-button span { color: var(--muted); }

.toolbar { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.toolbar .filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { min-width: min(260px, 100%); }
.list { display: grid; gap: 12px; }
.item {
    background: white;
    border: 1px solid var(--line);
    border-left: 5px solid var(--blue);
    border-radius: 8px;
    padding: 15px;
    display: grid;
    gap: 10px;
}
.item.green { border-left-color: var(--green); }
.item.red { border-left-color: var(--red); }
.item.orange { border-left-color: var(--orange); }
.item.yellow { border-left-color: var(--yellow); }
.item-head { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.item-title { font-weight: 800; }
.meta { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.empty {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    background: white;
}
.stat-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stat-row:last-child { border-bottom: 0; }
.phone-link { color: var(--blue); text-decoration: none; font-weight: 700; }

.alert-host { position: fixed; right: 22px; bottom: 22px; z-index: 20; display: grid; gap: 10px; }
.alert {
    width: min(360px, calc(100vw - 32px));
    border-radius: 8px;
    padding: 12px 14px;
    background: #102a43;
    color: white;
    box-shadow: 0 12px 30px rgba(16, 42, 67, 0.22);
}
.alert.error { background: var(--red); }
.alert.success { background: var(--green); }
.form-message { min-height: 20px; color: var(--red); font-weight: 700; }

dialog {
    width: min(560px, calc(100vw - 32px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 24px 80px rgba(16, 24, 40, 0.25);
}
dialog::backdrop { background: rgba(13, 36, 56, 0.45); }
.modal-box { padding: 18px; display: grid; gap: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.icon-btn { border: 1px solid var(--line); background: white; border-radius: 8px; min-width: 40px; min-height: 40px; font-size: 20px; }
#mobileMenuBtn { display: none; margin-right: 10px; }
.muted { color: var(--muted); }
.api-note { background: #fff8e5; border-color: #f2cc67; color: #6b4a00; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(300px, 86vw);
        transform: translateX(-104%);
        transition: transform 160ms ease;
        z-index: 10;
    }
    .sidebar.open { transform: translateX(0); }
    #mobileMenuBtn { display: inline-grid; place-items: center; }
    .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
    .topbar { padding: 16px; align-items: flex-start; }
    .view-host { padding: 16px; }
    h2 { font-size: 24px; }
}
