:root {
    --navy: #132238;
    --navy-2: #1d324d;
    --blue: #2878ff;
    --blue-dark: #175fd6;
    --ice: #f3f7fb;
    --white: #ffffff;
    --text: #1c2938;
    --muted: #6f7d8d;
    --border: #dfe7ef;
    --success: #137a4b;
    --success-bg: #e9f8f0;
    --danger: #b42318;
    --danger-bg: #fff0ee;
    --warning-bg: #fff7e6;
    --shadow: 0 18px 45px rgba(23, 42, 67, .10);
    --radius: 14px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--ice); }
body { margin: 0; min-height: 100vh; color: var(--text); background: var(--ice); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: var(--blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; }

.auth-page { display: grid; place-items: center; padding: 32px 16px; background: radial-gradient(circle at 15% 10%, #e1ecff, transparent 35%), var(--ice); }
.auth-shell { width: min(430px, 100%); }
.install-shell { width: min(820px, 100%); }
.auth-card, .install-card { background: var(--white); border: 1px solid rgba(223, 231, 239, .85); border-radius: 22px; box-shadow: var(--shadow); padding: clamp(26px, 5vw, 48px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); font-weight: 800; letter-spacing: .05em; }
.brand-large { margin-bottom: 32px; }
.brand-mark { display: inline-grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: var(--white); background: linear-gradient(145deg, var(--blue), #64a1ff); box-shadow: 0 7px 16px rgba(40, 120, 255, .28); font-size: .72rem; letter-spacing: 0; }
.brand > span:last-child { line-height: 1.2; }
.eyebrow { margin: 0 0 6px; color: var(--blue-dark); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .11em; }
h1, h2, h3 { color: var(--navy); line-height: 1.2; }
h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 4vw, 2.4rem); }
h2 { margin: 0; font-size: 1.28rem; }
.muted { color: var(--muted); }

.stack-form { display: grid; gap: 20px; margin-top: 28px; }
fieldset { display: grid; gap: 15px; margin: 0; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); }
legend { padding: 0 8px; color: var(--navy); font-weight: 750; }
label { display: grid; gap: 7px; color: #3a495a; font-size: .9rem; font-weight: 650; }
input, select { width: 100%; min-height: 44px; padding: 9px 12px; color: var(--text); background: var(--white); border: 1px solid #cfd9e4; border-radius: 9px; outline: 0; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(40, 120, 255, .13); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-inline { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.form-inline label { flex: 1 1 200px; }
.check-label { display: flex; align-items: center; gap: 8px; }
.check-label input { width: 18px; min-height: 18px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; cursor: pointer; font-weight: 750; text-decoration: none; transition: .18s ease; }
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-primary { color: var(--white); background: var(--blue); box-shadow: 0 7px 15px rgba(40, 120, 255, .20); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { color: var(--navy); background: var(--white); border-color: var(--border); }
.button-danger { color: var(--danger); background: var(--white); border-color: #efc5c0; }
.button-link { padding: 6px 8px; color: var(--blue-dark); background: transparent; }
.button-small { min-height: 34px; padding: 6px 10px; font-size: .82rem; }
.button-wide { width: 100%; min-height: 48px; }

.alert { margin: 18px 0; padding: 13px 15px; border-radius: 10px; font-size: .92rem; }
.alert ul { margin: 7px 0 0; padding-left: 20px; }
.alert-error { color: var(--danger); background: var(--danger-bg); border: 1px solid #f2c7c2; }
.alert-success { color: var(--success); background: var(--success-bg); border: 1px solid #b9e8cf; }
.alert-warning { color: #765000; background: var(--warning-bg); border: 1px solid #f0d79b; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 245px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; gap: 26px; padding: 25px 20px; color: #dce8f7; background: linear-gradient(175deg, var(--navy), #0d1b2e 72%); }
.sidebar .brand { color: var(--white); }
.nav { display: grid; gap: 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: #ccdaeb; border-radius: 9px; font-weight: 650; }
.nav a:hover, .nav a.active { color: var(--white); background: rgba(255, 255, 255, .10); text-decoration: none; }
.sidebar-footer { margin-top: auto; }
.user-chip { margin-bottom: 12px; padding: 12px; background: rgba(255, 255, 255, .08); border-radius: 10px; }
.user-chip strong, .user-chip span { display: block; }
.user-chip span { overflow: hidden; color: #9eb1c8; font-size: .78rem; text-overflow: ellipsis; }
.sidebar .button-link { width: 100%; color: #ccdaeb; }

.main { min-width: 0; padding: clamp(20px, 4vw, 42px); }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.topbar h1 { font-size: clamp(1.55rem, 3vw, 2rem); }
.breadcrumbs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 7px; color: var(--muted); font-size: .85rem; }
.top-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(23, 42, 67, .06); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.card-body { padding: 20px; }
.section-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.panel-stack { display: grid; gap: 20px; }

.file-table { width: 100%; border-collapse: collapse; }
.file-table th { padding: 11px 14px; color: var(--muted); background: #f8fafc; border-bottom: 1px solid var(--border); font-size: .74rem; text-align: left; text-transform: uppercase; letter-spacing: .06em; }
.file-table td { padding: 13px 14px; border-bottom: 1px solid #edf1f5; vertical-align: middle; }
.file-table tr:last-child td { border-bottom: 0; }
.file-table tr:hover td { background: #fbfdff; }
.file-name { display: flex; align-items: center; gap: 10px; min-width: 180px; font-weight: 700; }
.item-icon { display: inline-grid; flex: 0 0 auto; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: var(--blue-dark); background: #eaf2ff; font-size: .78rem; font-weight: 850; }
.item-icon.folder { color: #8a5b00; background: #fff4d7; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.actions form { margin: 0; }
.empty-state { padding: 48px 20px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--navy); font-size: 1.05rem; }
.level-badge { display: inline-flex; padding: 4px 8px; color: var(--blue-dark); background: #eaf2ff; border-radius: 999px; font-size: .75rem; font-weight: 750; }
.badge-stack { display: grid; justify-items: start; gap: 6px; }
.status-text { font-size: .78rem; font-weight: 750; }
.status-active { color: var(--success); }
.status-inactive { color: var(--danger); }
.status-pending { color: #765000; }
.upload-box { padding: 18px; border: 1px dashed #afbfce; border-radius: 11px; background: #fafcff; }
.upload-box input[type=file] { min-height: auto; padding: 8px; background: transparent; border: 0; }
.help { margin: 7px 0 0; color: var(--muted); font-size: .8rem; }
.permission-row { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(170px, .8fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.permission-row:last-child { border-bottom: 0; }
.person strong, .person span { display: block; }
.person span { color: var(--muted); font-size: .8rem; }
.table-wrap { overflow-x: auto; }

@media (max-width: 980px) {
    .section-grid { grid-template-columns: 1fr; }
    .panel-stack { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 740px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; padding: 15px; gap: 14px; }
    .sidebar .brand { margin-bottom: 2px; }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .nav a { justify-content: center; padding: 8px; font-size: .82rem; }
    .sidebar-footer { display: flex; align-items: center; gap: 10px; }
    .user-chip { flex: 1; margin: 0; }
    .main { padding: 18px 12px 32px; }
    .topbar { display: grid; }
    .form-grid, .panel-stack { grid-template-columns: 1fr; }
    .permission-row { grid-template-columns: 1fr; }
    .file-table th:nth-child(2), .file-table td:nth-child(2), .file-table th:nth-child(3), .file-table td:nth-child(3) { display: none; }
}
