:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-soft: #f0f2f7;
    --text: #17191f;
    --muted: #68707d;
    --border: #e3e6ec;
    --accent: #7b4d1d;
    --accent-strong: #5f3812;
    --accent-soft: #f4eadf;
    --danger: #a52b2b;
    --danger-soft: #fff0f0;
    --success: #176a3a;
    --success-soft: #eaf8ef;
    --shadow: 0 18px 48px rgba(28, 32, 39, 0.08);
    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 10px;
}
* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; }
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
.login-body { background: radial-gradient(circle at top left, rgba(123, 77, 29, .13), transparent 34rem), var(--bg); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 34px; }
.brand-mark { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--accent); color: #fff; font-weight: 800; font-size: 24px; margin-bottom: 22px; }
.brand-mark-small { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; margin: 0; flex: 0 0 auto; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(28px, 4vw, 38px); line-height: 1.1; }
h2 { margin-bottom: 6px; font-size: 21px; }
h3 { margin-bottom: 6px; font-size: 16px; }
.muted { color: var(--muted); }
.form-stack { display: grid; gap: 16px; margin-top: 26px; }
.field { display: grid; gap: 7px; font-size: 13px; font-weight: 700; min-width: 0; }
.field input:not([type=checkbox]), .field select, .field textarea, .search-row input, .search-row select, .data-table input, .data-table select { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 10px 12px; outline: none; color: var(--text); }
.field textarea { resize: vertical; min-height: 72px; }
.field input:focus, .field select:focus, .field textarea:focus, .search-row input:focus, .search-row select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[type=checkbox] { width: auto; margin-right: 7px; accent-color: var(--accent); }
.field small { font-weight: 500; }
.button { border: 0; border-radius: var(--radius-sm); min-height: 42px; padding: 10px 15px; cursor: pointer; font-weight: 750; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: var(--accent-strong); color: #fff; }
.button-ghost { background: var(--surface-soft); color: var(--text); }
.button-full { width: 100%; }
.alert { border-radius: var(--radius-sm); padding: 11px 13px; margin: 12px 0 18px; font-size: 13px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f4caca; }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #c9ead5; }
.login-foot { display: flex; gap: 8px; justify-content: center; color: var(--muted); font-size: 12px; margin-top: 24px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { height: 100vh; position: sticky; top: 0; align-self: start; overflow-y: auto; background: #17191f; color: #fff; padding: 20px 16px; display: flex; flex-direction: column; gap: 20px; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 14px; }
.sidebar-brand span { margin-top: 2px; color: #aeb4c0; font-size: 11px; }
.sidebar-nav { display: grid; gap: 4px; }
.nav-item { min-height: 39px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: #d9dde5; font-size: 12px; }
.nav-item small { margin-left: auto; color: #777f8d; font-size: 10px; }
.nav-item.is-active { background: #2a2d35; color: #fff; }
.nav-item.is-disabled { color: #8d94a0; cursor: default; }
.nav-icon { width: 22px; height: 22px; display: grid; place-items: center; background: rgba(255,255,255,.07); border-radius: 7px; font-size: 11px; font-weight: 800; flex: 0 0 auto; }
.sidebar-foot { margin-top: auto; display: grid; gap: 12px; }
.profile-mini { padding: 10px 4px; }
.profile-mini strong, .profile-mini span { display: block; }
.profile-mini strong { font-size: 13px; }
.profile-mini span { margin-top: 3px; color: #9ea5b2; font-size: 11px; }
.main-panel { min-width: 0; }
.topbar { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 12px 26px; background: rgba(255,255,255,.9); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; backdrop-filter: blur(10px); }
.topbar strong { font-size: 14px; }
.topbar-meta { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: #2e9c5b; box-shadow: 0 0 0 4px #e7f7ed; }
.content-area { padding: 30px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 24px; align-items: flex-start; }
.page-head-actions { align-items: center; }
.page-head p { max-width: 720px; }
.action-row, .form-actions, .search-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.search-row input, .search-row select { width: auto; min-width: 150px; flex: 1 1 180px; }
.panel-card, .stat-card, .module-card, .system-strip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.panel-card { padding: 18px; }
.form-panel { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; margin-top: 14px; }
.field-span-2 { grid-column: span 2; }
.form-actions { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { padding: 18px; display: grid; gap: 6px; }
.stat-card > span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat-card strong { font-size: 20px; }
.stat-card small { color: var(--muted); }
.section-block { margin-top: 28px; }
.section-title { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 13px; }
.section-title p { margin-bottom: 0; font-size: 13px; }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.module-card { padding: 18px; display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 14px; align-items: start; position: relative; }
.module-card p { color: var(--muted); font-size: 12px; line-height: 1.5; margin-bottom: 0; padding-right: 70px; }
.module-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
.pill { position: absolute; right: 14px; top: 14px; font-size: 9px; text-transform: uppercase; letter-spacing: .07em; font-weight: 800; color: var(--muted); background: var(--surface-soft); padding: 5px 7px; border-radius: 999px; }
.system-strip { padding: 16px 18px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 18px; }
.system-strip span, .system-strip strong { display: block; }
.system-strip span { font-size: 11px; }
.system-strip strong { margin-top: 3px; font-size: 13px; }
.table-card { padding: 0; overflow: hidden; }
.table-card > h2 { padding: 18px 18px 0; }
.table-scroll { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 680px; font-size: 12px; }
.data-table th { text-align: left; background: var(--surface-soft); color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; padding: 11px 12px; white-space: nowrap; }
.data-table td { padding: 11px 12px; border-top: 1px solid var(--border); vertical-align: top; }
.data-table tbody tr:hover { background: #fcfcfd; }
.data-table a { color: var(--accent); font-weight: 700; }
.data-table input, .data-table select { min-width: 82px; padding: 7px 8px; font-size: 11px; }
.table-note { display: block; color: var(--muted); margin-top: 3px; font-size: 10px; }
.table-actions { white-space: nowrap; }
.table-actions a + a { margin-left: 8px; }
.empty-state { display: grid; place-items: center; gap: 5px; min-height: 160px; color: var(--muted); text-align: center; padding: 24px; }
.empty-state strong { color: var(--text); }
.status-badge { display: inline-flex; padding: 4px 7px; border-radius: 999px; background: var(--surface-soft); font-size: 10px; font-weight: 800; }
.status-badge.is-active { background: var(--success-soft); color: var(--success); }
.detail-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(240px,1fr); gap: 14px; }
.detail-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.detail-list span, .detail-list strong { display: block; }
.detail-list span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.detail-list strong { margin-top: 4px; font-size: 13px; }
.balance-card { display: grid; gap: 6px; align-content: start; }
.balance-card > span { color: var(--muted); font-size: 11px; }
.balance-card > strong { font-size: 28px; }
.balance-card .small-value { font-size: 18px; }
.balance-card hr { width: 100%; border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.record-meta { display: flex; flex-wrap: wrap; gap: 16px; color: var(--muted); font-size: 11px; }
.record-meta strong { color: var(--text); }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }
details summary { cursor: pointer; color: var(--accent); font-weight: 700; }
details pre { max-width: 420px; max-height: 220px; overflow: auto; font-size: 10px; background: var(--surface-soft); padding: 8px; border-radius: 8px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 980px) {
    .app-shell { grid-template-columns: 82px minmax(0,1fr); }
    .sidebar { padding-inline: 12px; }
    .sidebar-brand > div:last-child, .nav-item > span:not(.nav-icon), .nav-item small, .profile-mini { display: none; }
    .sidebar-brand { justify-content: center; }
    .nav-item { justify-content: center; padding-inline: 6px; }
    .module-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 720px) {
    .app-shell { display: block; }
    .sidebar { height: auto; min-height: auto; position: static; padding: 12px; gap: 10px; overflow: visible; }
    .sidebar-brand { justify-content: flex-start; }
    .sidebar-brand > div:last-child { display: block; }
    .sidebar-nav { display: flex; overflow-x: auto; padding-bottom: 2px; }
    .nav-item { flex: 0 0 auto; min-height: 38px; padding-inline: 10px; }
    .nav-item > span:not(.nav-icon) { display: inline; }
    .nav-item small, .sidebar-foot { display: none; }
    .topbar { position: static; padding: 11px 16px; }
    .content-area { padding: 20px 15px 28px; }
    .page-head { display: grid; gap: 12px; }
    .stat-grid, .form-grid, .detail-grid, .detail-list { grid-template-columns: 1fr; }
    .field-span-2 { grid-column: auto; }
    .module-grid { grid-template-columns: 1fr; }
    .system-strip { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .search-row > * { flex: 1 1 100%; }
}
@media (max-width: 460px) {
    .login-card { padding: 26px 20px; }
    .stat-grid, .system-strip { grid-template-columns: 1fr; }
}
@media print {
    .sidebar, .topbar, .button, form { display: none !important; }
    .app-shell { display: block; }
    .content-area { max-width: none; padding: 0; }
    body { background: #fff; }
    .panel-card, .stat-card { break-inside: avoid; box-shadow: none; }
}
