:root {
    --navy: #17365d;
    --blue: #245b85;
    --sky: #eaf4fa;
    --line: #d7e2ea;
    --text: #1d2935;
    --muted: #647482;
    --white: #fff;
    --success: #176b45;
    --success-bg: #e5f4eb;
    --danger: #a32929;
    --danger-bg: #fdecec;
    --warning: #7a5600;
    --warning-bg: #fff3cd;
    --shadow: 0 8px 24px rgba(23, 54, 93, .08);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--text); background: #f5f8fa; }
body { margin: 0; min-height: 100vh; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
code { font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; color: #17365d; }

.topbar { height: 58px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; background: var(--navy); color: var(--white); }
.brand { color: var(--white); font-weight: 750; letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.user-menu { display: flex; gap: 18px; align-items: center; font-size: 14px; }
.user-menu a { color: #dceaf3; }
.user-menu form { margin: 0; }
.signout { border: 0; padding: 0; background: transparent; color: #dceaf3; font: inherit; cursor: pointer; }
.signout:hover { text-decoration: underline; }
.shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.sidebar { padding: 20px 12px; background: #fff; border-right: 1px solid var(--line); }
.nav-link { display: block; padding: 10px 12px; margin: 2px 0; color: #304657; border-radius: 7px; font-size: 14px; }
.nav-link:hover { background: var(--sky); text-decoration: none; }
.nav-link.active { background: #dceef8; color: var(--navy); font-weight: 700; }
.content { min-width: 0; padding: 26px; }

.public-page { display: grid; place-items: center; background: linear-gradient(140deg, #eef6fb, #f8fafb 50%, #e5eef5); padding: 24px; }
.public-content { width: 100%; max-width: 520px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 32px; box-shadow: var(--shadow); }
.install-card { max-width: 620px; margin: auto; }
.auth-card h1 { margin: 6px 0 8px; }

.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin: 0 0 20px; }
.page-heading h1 { margin: 2px 0 4px; font-size: 26px; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--blue); font-weight: 750; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.muted { color: var(--muted); }
.hint { display: block; color: var(--muted); font-size: 12px; font-weight: 400; margin: 2px 0 5px; }

.panel { background: var(--white); border: 1px solid var(--line); border-radius: 10px; padding: 20px; box-shadow: 0 2px 10px rgba(23, 54, 93, .035); }
.panel h2 { font-size: 18px; margin: 0 0 14px; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 390px); gap: 20px; align-items: start; }
.wide-form { min-width: 390px; }
.table-panel { min-width: 0; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: #405564; font-weight: 700; background: #f0f5f8; border-bottom: 1px solid var(--line); padding: 10px; white-space: nowrap; }
td { border-bottom: 1px solid #e7eef2; padding: 10px; vertical-align: top; }
tbody tr:hover { background: #f9fbfc; }
.actions { white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.form-grid { display: grid; gap: 14px; }
.single-column { grid-template-columns: 1fr; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: block; font-size: 13px; font-weight: 650; color: #344a59; }
input, select, textarea { width: 100%; margin-top: 5px; border: 1px solid #bdccd6; background: #fff; color: var(--text); border-radius: 6px; padding: 9px 10px; outline: 0; }
input:focus, select:focus, textarea:focus { border-color: #4d87ad; box-shadow: 0 0 0 3px rgba(77, 135, 173, .13); }
input[readonly] { background: #f2f4f5; }
textarea { resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; margin: 0; }
.button-row { display: flex; gap: 8px; align-items: center; }
.button { display: inline-flex; width: auto; align-items: center; justify-content: center; min-height: 38px; padding: 8px 14px; border: 1px solid #b8c9d4; border-radius: 6px; background: #fff; color: #27485f; cursor: pointer; font-weight: 650; font-size: 13px; }
.button:hover { background: #f2f7fa; text-decoration: none; }
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.button.primary:hover { background: #1d4c72; }
.text-button { border: 0; background: transparent; color: var(--danger); cursor: pointer; padding: 0; }
.top-gap { margin-top: 16px; }
.filter-bar { display: flex; gap: 8px; margin-bottom: 15px; }
.filter-bar input { margin: 0; min-width: 160px; }
.filter-bar select { margin: 0; max-width: 230px; }

.alert { border-radius: 7px; padding: 11px 13px; margin: 0 0 14px; border: 1px solid transparent; font-size: 14px; }
.alert-success { color: var(--success); background: var(--success-bg); border-color: #b9dfca; }
.alert-error { color: var(--danger); background: var(--danger-bg); border-color: #f0c4c4; }
.alert-warning { color: var(--warning); background: var(--warning-bg); border-color: #edd991; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 700; }
.status.active { background: var(--success-bg); color: var(--success); }
.status.inactive { background: #edf0f2; color: #687681; }
.tag { display: inline-flex; border-radius: 999px; padding: 2px 6px; background: #e8eff5; color: #456176; font-size: 10px; font-weight: 700; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.stat-card strong { display: block; font-size: 28px; color: var(--navy); }
.stat-card span { color: var(--muted); font-size: 13px; }
.requirement-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0; padding: 14px; background: #f5f8fa; border-radius: 8px; font-size: 13px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; }
.status-dot.ok { background: #2e9b68; }
.status-dot.bad { background: #c84b4b; }
.permission-grid { border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.permission-head, .permission-row { display: grid; grid-template-columns: 1fr 56px 56px; align-items: center; padding: 8px 10px; gap: 6px; }
.permission-head { background: #edf4f8; font-size: 12px; font-weight: 750; }
.permission-row { border-top: 1px solid var(--line); font-size: 12px; }
.permission-row label { text-align: center; }
.permission-row input { width: auto; margin: 0; }

@media (max-width: 1000px) {
    .split-layout { grid-template-columns: 1fr; }
    .form-panel { max-width: none; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { display: flex; gap: 4px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
    .nav-link { white-space: nowrap; }
    .content { padding: 16px; }
    .topbar { padding: 0 14px; }
    .page-heading { flex-direction: column; }
    .filter-bar { flex-wrap: wrap; }
    .two-cols, .requirement-list { grid-template-columns: 1fr; }
}
