:root {
  --kg-red: #4C0606;
  --kg-red-2: #6d1111;
  --black: #0b0b0b;
  --white: #ffffff;
  --paper: #fbfbfb;
  --muted: #5f5f5f;
  --line: #d8d8d8;
  --soft: #f2f2f2;
  --danger: #a40000;
  --ok: #155d27;
  --warning: #7a5200;
  --radius: 16px;
  --shadow: 0 16px 40px rgba(0,0,0,.12);
}
* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body { margin: 0; min-height: 100vh; font-family: Arial, Helvetica, sans-serif; color: var(--black); background: var(--paper); line-height: 1.35; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
a { color: var(--kg-red); }

.login-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: clamp(16px, 4vw, 42px); background: linear-gradient(120deg, rgba(76,6,6,.96), rgba(76,6,6,.78)); }
.login-card { width: min(560px, 100%); background: var(--white); border-radius: 24px; box-shadow: var(--shadow); padding: clamp(22px, 4vw, 36px); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { display: block; width: min(200px, 36vw); max-width: 200px; height: auto; object-fit: contain; flex: 0 0 auto; }
.login-logo { width: min(240px, 72vw); max-width: 240px; }
.brand-copy { min-width: 0; }
.brand-mark { width: 56px; height: 56px; border: 3px solid var(--kg-red); border-radius: 13px; display: grid; place-items: center; color: var(--kg-red); font-weight: 900; font-size: 32px; transform: skew(-8deg); }
.brand-title { font-size: 23px; font-weight: 900; color: var(--black); }
.brand-subtitle { color: var(--muted); font-size: 13px; margin-top: 3px; }
.login-card h1 { margin: 22px 0 6px; font-size: clamp(30px, 5vw, 46px); color: var(--kg-red); }
.login-card p { color: var(--muted); margin: 0 0 18px; }
.login-tabs { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.login-tabs button { border: 1px solid var(--line); background: var(--white); color: var(--black); border-radius: 99px; padding: 9px 13px; font-weight: 800; }
.login-tabs button.active { background: var(--kg-red); color: var(--white); border-color: var(--kg-red); }

.topbar { position: sticky; top: 0; z-index: 30; width: 100%; background: var(--white); border-bottom: 4px solid var(--kg-red); padding: 12px clamp(14px, 2vw, 28px); display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.topbar .brand { cursor: pointer; }
.top-actions { display: flex; gap: 9px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.user-pill { max-width: 320px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border: 1px solid var(--line); border-radius: 99px; padding: 8px 11px; background: var(--soft); font-size: 13px; }
.container { width: 100%; max-width: none; margin: 0; padding: clamp(14px, 2vw, 28px); }
.page-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.page-head h1 { color: var(--kg-red); margin: 8px 0 4px; font-size: clamp(28px, 4vw, 42px); }
.page-head p { color: var(--muted); margin: 0; max-width: 820px; }

.btn { border: 2px solid var(--kg-red); background: var(--kg-red); color: var(--white); border-radius: 12px; padding: 10px 14px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; text-decoration: none; }
.btn:hover, .btn:focus-visible { background: var(--kg-red-2); outline: 3px solid rgba(76,6,6,.18); }
.btn.secondary { background: var(--white); color: var(--kg-red); }
.btn.secondary:hover { background: #fff3f3; }
.btn.black { background: var(--black); border-color: var(--black); color: var(--white); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--black); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--white); }
.btn.small { min-height: 32px; padding: 6px 9px; border-radius: 9px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.field-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; align-items: start; }
.field { grid-column: span 6; }
.field.full { grid-column: 1 / -1; }
.field.third { grid-column: span 4; }
.field.quarter { grid-column: span 3; }
.field.two-thirds { grid-column: span 8; }
label { display: block; font-weight: 900; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"], input[type="number"], input[type="datetime-local"], select, textarea {
  width: 100%; border: 1.8px solid #b8b8b8; border-radius: 10px; padding: 10px 11px; min-height: 42px; background: var(--white); color: var(--black); font-size: 15px;
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(76,6,6,.18); border-color: var(--kg-red); }
.hint { color: var(--muted); font-size: 12px; margin-top: 5px; }
.check-field { display: flex; gap: 9px; align-items: center; min-height: 42px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.check-field input { width: 20px; height: 20px; accent-color: var(--kg-red); }
.radio-group { display: flex; flex-wrap: wrap; gap: 10px; }
.radio-pill { border: 1.8px solid #b8b8b8; border-radius: 99px; padding: 9px 12px; background: #fff; display: flex; gap: 7px; align-items: center; font-weight: 800; }
.radio-pill input { accent-color: var(--kg-red); }

.hero { background: var(--white); border: 1px solid var(--line); border-radius: 24px; box-shadow: 0 8px 24px rgba(0,0,0,.06); padding: 24px; margin-bottom: 22px; display: grid; grid-template-columns: 1.4fr .85fr; gap: 20px; align-items: center; }
.hero h1 { color: var(--kg-red); font-size: clamp(32px, 5vw, 52px); margin: 0; }
.hero p { color: var(--muted); margin: 8px 0 0; }
.system-widget { border: 2px solid var(--kg-red); border-radius: 18px; padding: 16px; background: var(--white); }
.dashboard-head { width: 100%; background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: clamp(16px, 2.2vw, 24px); margin-bottom: 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; box-shadow: 0 8px 22px rgba(0,0,0,.05); }
.dashboard-head h1 { margin: 0; color: var(--kg-red); font-size: clamp(30px, 4vw, 48px); line-height: 1; }
.dashboard-stats { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 285px), 1fr)); gap: clamp(12px, 1.6vw, 22px); align-items: stretch; }
.form-card { background: var(--white); border: 2px solid var(--black); border-radius: 22px; min-height: clamp(178px, 22vw, 235px); padding: clamp(16px, 1.8vw, 22px); text-align: left; display: flex; flex-direction: column; justify-content: space-between; transition: .12s ease; color: var(--black); }
.form-card:hover, .form-card:focus-visible { transform: translateY(-2px); border-color: var(--kg-red); box-shadow: 0 16px 34px rgba(76,6,6,.16); outline: none; }
.icon-box { width: 62px; height: 62px; border-radius: 18px; background: var(--kg-red); color: var(--white); display: grid; place-items: center; margin-bottom: 14px; }
.icon-box svg { width: 34px; height: 34px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.form-card h2 { margin: 0 0 6px; font-size: 21px; }
.form-card p { margin: 0; color: var(--muted); font-size: 14px; }
.card-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.badge { border: 1px solid var(--line); border-radius: 99px; padding: 5px 9px; font-size: 12px; color: var(--black); background: var(--soft); display: inline-flex; gap: 5px; align-items: center; }
.badge.red { background: var(--kg-red); color: var(--white); border-color: var(--kg-red); }
.badge.ok { background: #eef8f0; color: var(--ok); border-color: #b6dec0; }
.badge.warn { background: #fff6e4; color: var(--warning); border-color: #e6ca82; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 13px; margin-bottom: 18px; }
.stat-card { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 16px; }
.stat-card .num { font-size: 31px; font-weight: 900; color: var(--kg-red); line-height: 1; }
.stat-card .label { color: var(--muted); margin-top: 6px; font-size: 13px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 6px 18px rgba(0,0,0,.04); margin-bottom: 18px; overflow: hidden; }
.panel-head { border-bottom: 1px solid var(--line); padding: 16px 18px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-body { padding: 18px; }
.empty-state { color: var(--muted); padding: 14px; background: var(--soft); border-radius: 12px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; font-size: 14px; }
th { background: var(--kg-red); color: var(--white); font-weight: 900; white-space: nowrap; }
tr:hover td { background: #fbf7f7; }
.data-table td:last-child, .data-table th:last-child { text-align: right; white-space: nowrap; }

.form-header-card { background: var(--white); border: 1px solid var(--line); border-radius: 20px; padding: 18px; margin-bottom: 18px; box-shadow: 0 8px 20px rgba(0,0,0,.04); }
.form-title-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.form-title-row h1 { color: var(--kg-red); margin: 10px 0 0; font-size: clamp(27px, 4vw, 40px); }
.save-indicator { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 99px; background: var(--ok); display: inline-block; }
.audit-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; background: #fff7f7; border: 1px solid #e7bcbc; padding: 13px; border-radius: 14px; }
.form-section { background: var(--white); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-bottom: 16px; overflow: hidden; }
.form-section h2 { margin: -18px -18px 16px; padding: 13px 18px; background: var(--black); color: var(--white); font-size: 18px; }
.repeat-table { border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.repeat-table table { min-width: 900px; }
.repeat-table th { background: var(--kg-red); color: var(--white); }
.repeat-table td { padding: 7px; }
.repeat-table input, .repeat-table select, .repeat-table textarea { min-height: 36px; font-size: 14px; padding: 7px 8px; border-radius: 8px; }
.repeat-table textarea { min-height: 58px; }
.table-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.footer-actions { position: sticky; bottom: 0; z-index: 20; background: rgba(250,250,250,.96); border-top: 1px solid var(--line); padding: 13px 0; backdrop-filter: blur(8px); }
.footer-actions .container { padding-top: 0; padding-bottom: 0; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.admin-grid { display: grid; grid-template-columns: minmax(280px, .7fr) 1fr; gap: 18px; }
.permission-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px; max-height: 480px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.permission-item { border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; gap: 8px; align-items: flex-start; background: var(--white); }
.permission-item input { margin-top: 3px; accent-color: var(--kg-red); }
.reset-token { white-space: pre-wrap; word-break: break-word; background: #fff7f7; border: 1px solid #e7bcbc; padding: 12px; border-radius: 12px; }

.toast { position: fixed; right: 18px; bottom: 18px; background: var(--black); color: white; padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow); z-index: 60; opacity: 0; pointer-events: none; transform: translateY(8px); transition: all .18s ease; max-width: min(420px, calc(100vw - 36px)); }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 920px) {
  .hero, .admin-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .top-actions { width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: 2px; }
  .top-actions .btn, .top-actions .user-pill { flex: 0 0 auto; }
  .audit-strip { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .field, .field.third, .field.quarter, .field.two-thirds { grid-column: 1 / -1; }
  .container { padding: 14px; }
  .login-card { padding: 22px; border-radius: 18px; }
  .page-head { flex-direction: column; }
  .dashboard-head { align-items: flex-start; }
  .dashboard-stats { justify-content: flex-start; }
  .audit-strip { grid-template-columns: 1fr; }
  .brand-logo { width: min(180px, 58vw); }
  .brand-copy { display: none; }
  .form-card p { font-size: 13px; }
  .footer-actions .container { align-items: stretch; }
  .footer-actions .button-row { width: 100%; }
  .footer-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 480px) {
  .login-tabs { display: grid; grid-template-columns: 1fr; }
  .top-actions { gap: 6px; }
  .top-actions .btn.small { font-size: 12px; padding: 6px 8px; }
  .user-pill { max-width: 100%; }
  .cards-grid { grid-template-columns: 1fr; }
}
@media print { .topbar, .footer-actions, .btn, .toast { display: none !important; } .container { max-width: none; padding: 0; } body { background: white; } .panel, .form-section, .form-header-card { box-shadow: none; break-inside: avoid; } }
