:root {
  --bg: #f0f5f8;
  --surface: #ffffff;
  --ink: #163047;
  --muted: #5a7388;
  --line: #d5e2ec;
  --brand: #0d6e8a;
  --brand-2: #0a5670;
  --brand-soft: #e4f3f8;
  --accent: #c47a2a;
  --danger: #c0392b;
  --warn: #b7791f;
  --ok: #1a7a4c;
  --shadow: 0 8px 24px rgba(13, 110, 138, 0.08);
  --radius: 14px;
  --sidebar: 260px;
  --font: "Be Vietnam Pro", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1100px 480px at 8% -12%, #d5eef5 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e8eef5 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  min-height: 100vh;
  line-height: 1.45;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-2); }

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  background: linear-gradient(180deg, #0a5670 0%, #0d6e8a 50%, #0b5f78 100%);
  color: #edf7fb; display: flex; flex-direction: column; z-index: 100;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; gap: 12px; align-items: center;
  padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  background: #f0c27a; color: #163047;
  display: grid; place-items: center; font-weight: 700; flex-shrink: 0;
}
.sidebar-brand strong { display: block; font-size: 15px; }
.sidebar-brand small { color: rgba(255,255,255,.7); font-size: 11px; display: block; max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: block; padding: 10px 12px; border-radius: 10px;
  color: rgba(255,255,255,.88); font-weight: 500; font-size: 14px;
}
.sidebar-nav a:hover, .sidebar-nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav-group {
  margin: 12px 12px 4px; font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; color: rgba(255,255,255,.45); font-weight: 600;
}

.sidebar-footer {
  padding: 14px; border-top: 1px solid rgba(255,255,255,.1);
}
.user-chip strong { display: block; font-size: 13px; }
.user-chip small { color: rgba(255,255,255,.65); font-size: 12px; }
.logout {
  display: inline-block; margin-top: 10px; color: #ffd8d8 !important;
  font-size: 13px; font-weight: 600;
}

.main { margin-left: var(--sidebar); flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 24px 8px; position: sticky; top: 0; z-index: 20;
  background: linear-gradient(180deg, rgba(240,245,248,.95), rgba(240,245,248,.7));
  backdrop-filter: blur(8px);
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.menu-btn {
  display: none; border: 0; background: var(--surface); width: 40px; height: 40px;
  border-radius: 10px; font-size: 18px; cursor: pointer; box-shadow: var(--shadow);
}
.content { padding: 8px 24px 32px; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 16px; }
.card-body { padding: 18px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 700; margin-top: 4px; color: var(--brand-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600;
  cursor: pointer; background: var(--brand); color: #fff;
}
.btn:hover { background: var(--brand-2); color: #fff; }
.btn-outline { background: #fff; color: var(--brand); border: 1px solid var(--line); }
.btn-outline:hover { background: var(--brand-soft); color: var(--brand-2); }
.btn-danger { background: var(--danger); }
.btn-sm { padding: 7px 10px; font-size: 13px; border-radius: 8px; }
.btn-accent { background: var(--accent); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; }
tr:hover td { background: #f8fbfd; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(13,110,138,.25); border-color: var(--brand);
}
textarea { min-height: 90px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.alert {
  padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500;
}
.alert-success { background: #e8f7ef; color: var(--ok); border: 1px solid #b7e4c7; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c2; }

.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand-2);
}
.badge-waiting { background: #fff4e5; color: var(--warn); }
.badge-examining { background: #e4f3f8; color: var(--brand); }
.badge-done { background: #e8f7ef; color: var(--ok); }
.badge-cancelled { background: #f0f0f0; color: #666; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 180px; }
.search-box { display: flex; gap: 8px; flex: 1; }

.brand-mark.lg { width: 56px; height: 56px; font-size: 18px; border-radius: 16px; }
.login-body {
  background: linear-gradient(145deg, #0a5670 0%, #0d6e8a 40%, #1a6f88 70%, #245a70 100%) !important;
  min-height: 100vh;
}
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 440px; background: #fff;
  border-radius: 20px; border: 1px solid rgba(255,255,255,.3);
  box-shadow: 0 24px 60px rgba(0,0,0,.22); padding: 28px;
}
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; color: var(--ink); }
.login-card .sub { color: var(--muted); margin: 0; font-size: 13px; line-height: 1.45; }
.login-card .field { margin-bottom: 14px; }
.btn-lg { padding: 13px 16px; font-size: 15px; }
.login-modules {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; padding-top: 16px;
  border-top: 1px solid var(--line);
}
.login-modules span {
  font-size: 11px; font-weight: 600; color: var(--brand-2);
  background: var(--brand-soft); padding: 4px 8px; border-radius: 999px;
}

.page-intro {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  align-items: flex-end; margin-bottom: 14px;
}
.page-title { font-size: 18px; margin: 0 0 4px; }
.page-desc { margin: 0; color: var(--muted); font-size: 13px; }
.filter-bar { align-items: center; gap: 8px; }
.filter-bar label { margin: 0; font-size: 12px; }
.tip-box {
  background: #fff8eb; border: 1px solid #f0d9a8; color: #7a5a1a;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 14px;
}
.stat.accent { border-color: #f0c27a; background: linear-gradient(180deg, #fffaf0, #fff); }
.stat.accent .value { color: #a05a12; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { transform: translateX(-105%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; place-items: center; }
  .stats { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .toolbar, .actions, .btn, .alert { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
}
