:root {
  --brown: #0f4f61;
  --brown-2: #6fa6ad;
  --cream: #f7fbfb;
  --cream-2: #e9f2f3;
  --ink: #172b31;
  --muted: #5b7379;
  --line: #d5e4e6;
  --green: #2f7d55;
  --red: #a23b3b;
  --gold: #a97822;
  --blue: #376b8d;
  --shadow: 0 14px 34px rgba(15, 79, 97, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; overflow-x: hidden; }
body { margin: 0; background: linear-gradient(180deg, #f8fcfc, #edf5f6); color: var(--ink); }
body { overflow-x: hidden; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app { min-height: 100vh; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 52% 0%, rgba(255,255,255,.7), transparent 26%), linear-gradient(145deg, #164f61, #0a3543 58%, #082832); }
.login-card { width: min(960px, 100%); display: grid; grid-template-columns: minmax(280px, .9fr) minmax(320px, 1.1fr); background: white; border: 1px solid rgba(255,255,255,.34); border-radius: 8px; box-shadow: 0 24px 70px rgba(5, 34, 43, .32); overflow: hidden; }
.brand-panel { background: radial-gradient(circle at 50% 0%, rgba(255,255,255,.24), transparent 28%), linear-gradient(160deg, #1a6678, #0b3d4d 62%, #082934); color: white; padding: 42px; display: flex; flex-direction: column; gap: 24px; justify-content: space-between; }
.brand-panel img, .brand-logo img { width: 180px; max-width: 100%; background: #0f4f61; border-radius: 8px; padding: 8px; box-shadow: 0 10px 22px rgba(6, 38, 48, .22); }
.brand-panel h1 { color: #ffffff; font-size: 36px; font-weight: 800; line-height: 1.05; margin: 0; letter-spacing: 0; text-shadow: 0 2px 12px rgba(3, 25, 32, .42); }
.brand-panel p { color: #ffffff; font-weight: 520; line-height: 1.55; text-shadow: 0 1px 8px rgba(3, 25, 32, .34); }
.login-form { padding: 42px; display: grid; gap: 18px; align-content: center; }
.toolbar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; padding: 14px 22px; background: rgba(248, 252, 252, .94); border-bottom: 1px solid var(--line); backdrop-filter: blur(10px); }
.brand-logo { display: flex; align-items: center; gap: 12px; min-width: 240px; }
.brand-logo img { width: 78px; padding: 4px; }
.brand-logo strong { display: block; color: var(--brown); }
.brand-logo span { display: block; color: var(--muted); font-size: 12px; }
.shell { display: grid; grid-template-columns: 244px minmax(0, 1fr); min-height: calc(100vh - 70px); min-width: 0; }
.sidebar { padding: 18px; border-right: 1px solid var(--line); background: #edf6f7; }
.nav-btn { width: 100%; min-height: 42px; border: 0; background: transparent; color: var(--brown); display: flex; align-items: center; gap: 10px; border-radius: 8px; padding: 10px 12px; text-align: left; margin-bottom: 4px; }
.nav-btn.active, .nav-btn:hover { background: white; box-shadow: 0 0 0 1px var(--line); color: #073846; }
.main { padding: clamp(14px, 2vw, 24px); max-width: 1440px; width: 100%; min-width: 0; margin: 0 auto; }
.top-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; }
h1, h2, h3 { color: var(--brown); margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(24px, 3vw, 30px); }
h2 { font-size: clamp(19px, 2.4vw, 22px); margin-bottom: 14px; }
h3 { font-size: 17px; }
.subtle { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.metrics { grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: clamp(14px, 2vw, 18px); min-width: 0; }
.card::selection { background: #cfe5e9; }
.metric { min-height: 104px; display: grid; align-content: space-between; border-top: 4px solid var(--brown-2); }
.metric b { font-size: 28px; color: var(--brown); }
.metric span { color: var(--muted); font-size: 13px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; min-width: 0; }
.btn { border: 1px solid var(--line); background: white; color: var(--brown); border-radius: 8px; min-height: 38px; padding: 8px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; max-width: 100%; }
.btn.primary { background: var(--brown); color: white; border-color: var(--brown); box-shadow: 0 8px 18px rgba(15, 79, 97, .18); }
.btn.primary:hover { background: #0b3d4d; }
.btn.danger { color: var(--red); border-color: #e6bbbb; }
.btn.good { color: var(--green); border-color: #b9d8c6; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon { width: 18px; text-align: center; flex: 0 0 18px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 650; color: var(--brown); font-size: 13px; }
input, select, textarea { width: 100%; border: 1px solid var(--line); background: #fbfefe; border-radius: 8px; min-height: 40px; padding: 9px 10px; color: var(--ink); }
input[type="checkbox"] { width: auto; min-height: 0; padding: 0; }
textarea { min-height: 94px; resize: vertical; }
.readonly-field { min-height: 40px; display: flex; align-items: center; border: 1px solid var(--line); background: #f4fafb; border-radius: 8px; padding: 9px 10px; color: var(--muted); }
.check-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #f4fafb; border-radius: 8px; padding: 7px 9px; color: var(--brown); font-size: 13px; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: span 2; }
.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 8px; background: white; max-width: 100%; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #edf6f7; color: var(--brown); font-size: 13px; }
tr:hover td { background: #f6fbfb; }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 9px; font-size: 12px; border: 1px solid var(--line); background: #f4fafb; color: var(--brown); white-space: nowrap; }
.pill.green { background: #edf8f1; border-color: #bfe0ca; color: var(--green); }
.pill.red { background: #fff0ee; border-color: #e9c3bf; color: var(--red); }
.pill.gold { background: #fff7df; border-color: #efd99f; color: var(--gold); }
.pill.blue { background: #edf6fb; border-color: #bbd5e6; color: var(--blue); }
.notice { border-left: 4px solid var(--gold); background: #fff7df; padding: 12px; border-radius: 8px; color: #614415; }
.notice.danger { border-color: var(--red); background: #fff0ee; color: var(--red); }
.notice.good { border-color: var(--green); background: #edf8f1; color: var(--green); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 16px; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv span:first-child { color: var(--muted); }
.notif { position: relative; }
.badge { background: var(--red); color: white; border-radius: 999px; min-width: 20px; height: 20px; display: inline-grid; place-items: center; font-size: 12px; }
.canvas-card canvas { width: 100%; height: 260px; display: block; }
.mobile-only { display: none; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.lang { min-width: 86px; }
.role-chip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.print-report { display: none; }

@media (max-width: 960px) {
  .login-card, .shell, .detail-grid, .two, .three { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar > .btn-row { justify-content: flex-end; flex: 1 1 360px; }
  .sidebar { position: sticky; top: 95px; z-index: 3; border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px; scrollbar-width: thin; }
  .nav-btn { min-width: 138px; justify-content: center; white-space: nowrap; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .brand-logo { min-width: 0; }
  .brand-logo span { display: none; }
  table { min-width: 760px; }
}

@media (max-width: 620px) {
  .login-shell { padding: 12px; align-items: start; }
  .login-card { grid-template-columns: 1fr; width: 100%; }
  .toolbar { align-items: stretch; padding: 10px; }
  .toolbar > .btn-row { width: 100%; flex: 1 1 100%; justify-content: stretch; display: grid; grid-template-columns: 1fr 94px; }
  .toolbar .notif, .toolbar .role-chip, .toolbar .btn-row > .btn:last-child { grid-column: span 1; }
  .toolbar .role-chip { max-width: none; justify-content: center; }
  .toolbar .btn-row > .btn:last-child { min-width: 0; }
  .brand-logo { width: 100%; }
  .brand-logo img { width: 56px; }
  .brand-logo strong { font-size: 15px; line-height: 1.2; }
  .sidebar { top: 151px; padding: 8px 10px; }
  .nav-btn { min-width: 112px; min-height: 38px; padding: 8px 10px; font-size: 13px; }
  .top-actions { align-items: stretch; }
  .top-actions > * { width: 100%; }
  .top-actions .btn-row, .top-actions .btn { width: 100%; }
  .btn-row .btn, .btn-row select, .lang { flex: 1 1 auto; }
  .main { padding: 12px; }
  .metrics { gap: 10px; }
  .metric { min-height: 86px; }
  .metric b { font-size: 24px; }
  .login-form, .brand-panel { padding: 22px; }
  .brand-panel img { width: 132px; }
  .brand-panel h1 { font-size: 28px; }
  .brand-panel p { margin-bottom: 0; }
  .card { box-shadow: 0 8px 22px rgba(15, 79, 97, .08); }
  .canvas-card canvas { height: 220px; }
  .kv { grid-template-columns: 1fr; gap: 3px; }
  table { min-width: 680px; }
  th, td { padding: 9px 10px; }
  .pill { white-space: normal; }
}

@media (max-width: 430px) {
  .toolbar > .btn-row { grid-template-columns: 1fr; }
  .sidebar { top: 236px; }
  .nav-btn { min-width: 102px; }
  .btn { width: 100%; }
  .check { white-space: normal; width: 100%; }
  table { min-width: 620px; }
  .table-wrap { margin-left: -2px; margin-right: -2px; }
}
