:root {
  --bg: #f6fbff;
  --panel: #ffffff;
  --panel-2: #edf8ff;
  --text: #122033;
  --muted: #66788f;
  --line: #d8e8f2;
  --sky: #0ea5e9;
  --blue: #075985;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #b7791f;
  --violet: #7c3aed;
  --shadow: 0 14px 34px rgba(14, 76, 116, .09);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(180deg, #eef9ff 0, var(--bg) 260px);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; }
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.login-brand {
  padding: 34px;
  background: linear-gradient(135deg, #e2f6ff, #ffffff);
}
.brand-row { display: flex; gap: 12px; align-items: center; }
.brand-logo { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 8px 20px rgba(14, 165, 233, .16); }
.brand-title { margin: 0; font-size: 24px; line-height: 1.1; color: #0f2b42; }
.brand-sub { margin: 4px 0 0; color: var(--muted); font-weight: 700; }
.login-brand h2 { margin: 42px 0 12px; font-size: 34px; line-height: 1.08; }
.login-brand p { color: #38536b; line-height: 1.65; }
.login-points { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 24px; }
.login-points div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-weight: 800; color: #22445f; }
.login-form { padding: 34px; display: grid; align-content: center; }

.layout { display: grid; grid-template-columns: 284px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: rgba(255,255,255,.92);
  border-right: 1px solid var(--line);
  padding: 16px;
}
.sidebar .brand-row { margin-bottom: 18px; }
.nav { display: grid; gap: 5px; }
.nav button {
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 9px;
  padding: 10px 12px;
  color: #38536b;
  font-weight: 800;
}
.nav button:hover, .nav button.active { background: var(--panel-2); color: var(--blue); }
.nav-label { margin: 16px 0 6px; font-size: 11px; color: #91a5b8; font-weight: 900; text-transform: uppercase; }
.main { min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 66px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 22px;
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.page-title h1 { margin: 0; font-size: 24px; }
.page-title p { margin: 4px 0 0; color: var(--muted); font-weight: 700; }
.top-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { min-width: 280px; }
.content { padding: 22px; display: grid; gap: 16px; }
.content > * { min-width: 0; }

.grid { display: grid; gap: 14px; }
.kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-col { grid-template-columns: 1.2fr .9fr; }
.three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.person-card h2, .message-card h2 { margin: 0 0 8px; font-size: 18px; }
.person-card p, .message-card p { color: var(--muted); line-height: 1.55; }
.meter { height: 8px; background: #e5f2f8; border-radius: 999px; overflow: hidden; margin-top: 14px; }
.meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--sky)); }
.kpi-card { position: relative; overflow: hidden; }
.kpi-card:after {
  content: "";
  position: absolute;
  right: -26px;
  top: -26px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(14, 165, 233, .1);
}
.kpi-card span { color: var(--muted); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.kpi-card strong { display: block; margin-top: 8px; font-size: 29px; color: var(--blue); }
.kpi-card small { color: var(--green); font-weight: 800; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-weight: 700; font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.btn {
  border: 1px solid #b9dced;
  background: #fff;
  color: #0b5e95;
  border-radius: 9px;
  padding: 10px 12px;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn.primary { background: linear-gradient(135deg, var(--sky), var(--blue)); border-color: transparent; color: #fff; }
.btn.danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn.ghost { background: transparent; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--blue); font-weight: 900;
}

.field { display: grid; gap: 6px; margin-bottom: 12px; }
label { font-size: 12px; color: #34556f; font-weight: 900; text-transform: uppercase; }
input, select, textarea {
  width: 100%;
  border: 1px solid #c9ddea;
  background: #fff;
  border-radius: 9px;
  color: var(--text);
  padding: 11px 12px;
  outline: 0;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(14,165,233,.14); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

.table-wrap { width: 100%; max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
table { width: 100%; min-width: 760px; border-collapse: collapse; }
th, td { padding: 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { background: #f0f8fd; color: #31526e; font-size: 12px; text-transform: uppercase; }
td { font-size: 14px; }
.muted { color: var(--muted); font-weight: 800; }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; border: 1px solid #c8ddeb; font-size: 12px; font-weight: 900; color: #31526e; background: #f7fbfe; }
.badge.green { color: #166534; background: #ecfdf3; border-color: #bbf7d0; }
.badge.red { color: #991b1b; background: #fef2f2; border-color: #fecaca; }
.badge.amber { color: #92400e; background: #fffbeb; border-color: #fde68a; }
.badge.blue { color: #075985; background: #effaff; border-color: #bae6fd; }
.badge.violet { color: #5b21b6; background: #f5f3ff; border-color: #ddd6fe; }

.smart-panel {
  background: linear-gradient(135deg, #e3f6ff, #ffffff);
  border: 1px solid #c7e8f7;
  border-radius: 10px;
  padding: 16px;
}
.smart-panel h2 { margin: 0 0 8px; }
.smart-panel p { color: #38536b; margin: 0 0 12px; line-height: 1.55; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: #fff; border: 1px solid var(--line); color: #31526e; border-radius: 999px; padding: 8px 10px; font-weight: 800; }
.flow-line { display: flex; gap: 8px; flex-wrap: wrap; }
.flow-line span {
  background: #fff;
  border: 1px solid var(--line);
  color: #31526e;
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 900;
  font-size: 12px;
}

.calendar { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: 10px; overflow-x: auto; }
.day { min-height: 132px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; }
.day b { display: block; margin-bottom: 8px; }
.event { border: 1px solid #bae6fd; background: #f0faff; border-radius: 8px; padding: 8px; margin-top: 6px; font-size: 12px; }
.signature-box { height: 92px; border: 1px dashed #9fb7c9; border-radius: 10px; background: repeating-linear-gradient(45deg,#fff,#fff 10px,#f7fbfe 10px,#f7fbfe 20px); }
.toast { position: fixed; right: 18px; bottom: 86px; background: #0f2b42; color: #fff; border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); transition: .18s; z-index: 40; }
.toast.show { opacity: 1; transform: translateY(0); }
.modal { width: min(760px, calc(100% - 24px)); border: 0; border-radius: 14px; padding: 0; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(15, 32, 51, .42); }
.modal-card { margin: 0; padding: 18px; position: relative; }
.close-btn { position: absolute; right: 14px; top: 14px; }
.modal h2 { margin: 0 48px 16px 0; }

.bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
  z-index: 10;
  justify-content: space-around;
}
.bottom-nav button { border: 0; background: transparent; color: var(--muted); font-size: 11px; font-weight: 900; padding: 6px; }
.bottom-nav button.active { color: var(--sky); }

.print-sheet { background: #fff; color: #111827; padding: 24px; border: 1px solid #d1d5db; }
.print-head { display: flex; justify-content: space-between; gap: 14px; border-bottom: 3px solid var(--blue); padding-bottom: 10px; margin-bottom: 14px; }
.print-logo { font-size: 30px; font-weight: 900; color: var(--blue); }
.print-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.print-table th, .print-table td { border: 1px solid #cbd5e1; padding: 8px; white-space: normal; }
.print-table th { background: #e8f4fb; color: #0b3b75; width: 22%; }
.sign-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 70px; margin-top: 52px; }
.sign-line { border-top: 1px solid #111827; padding-top: 8px; }

@media (max-width: 1100px) {
  .kpi-grid, .three-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .login-card, .layout, .form-grid { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { align-items: flex-start; flex-direction: column; padding: 14px; }
  .search { min-width: 100%; }
  .content { padding: 14px 14px 82px; }
  .kpi-grid, .three-col { grid-template-columns: 1fr; }
  .bottom-nav { display: flex; }
  .login-points { grid-template-columns: 1fr; }
  .login-brand h2 { font-size: 28px; }
}
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .bottom-nav, .toolbar, .btn, .icon-btn, .toast { display: none !important; }
  .layout, .main { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
}
