:root {
  --navy: #12233d;
  --navy-light: #1c3459;
  --blue: #2563eb;
  --teal: #0f9488;
  --gray-50: #f7f8fa;
  --gray-100: #eef0f3;
  --gray-200: #e2e5ea;
  --gray-400: #9aa3b2;
  --gray-600: #5b6472;
  --gray-800: #262d3a;
  --red: #dc2626;
  --orange: #d97706;
  --green: #16a34a;
  --purple: #7c3aed;
  --white: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 30, 50, 0.08), 0 1px 2px rgba(20, 30, 50, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--navy);
  color: #dbe3f0;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  padding: 0 20px 20px 20px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 12px;
}
.sidebar .brand small { display:block; font-weight:400; font-size: 11px; color: #9db2d9; margin-top:2px; }

.sidebar nav a {
  display: block;
  padding: 10px 20px;
  color: #c4d0e6;
  font-size: 14px;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: var(--navy-light); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--navy-light); border-left-color: var(--blue); color: #fff; font-weight: 600; }

.sidebar .sidebar-footer {
  margin-top: auto;
  padding: 12px 20px 0 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
  color: #93a2bd;
}
.sidebar .sidebar-footer a { color: #c4d0e6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }

.content { padding: 24px 28px 60px 28px; }

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 20px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat-card .label { font-size: 12px; color: var(--gray-600); margin-top: 4px; }
.stat-card.highlight { border-color: var(--blue); background: #eff6ff; }
.stat-card.warn { border-color: var(--orange); background: #fffbeb; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--gray-600); font-weight: 600; background: var(--gray-50); }
tr:hover td { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-gray { background: #eef0f3; color: #4b5563; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-teal { background: #ccfbf1; color: #0f766e; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-orange { background: #fef3c7; color: #b45309; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-800);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--gray-50); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12.5px; font-weight: 600; color: var(--gray-600); }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=date], input[type=search], select, textarea {
  padding: 9px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--gray-800);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--blue); }
textarea { resize: vertical; min-height: 70px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; justify-content: space-between; }
.toolbar .filters { display: flex; gap: 10px; flex-wrap: wrap; }

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13.5px; }
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.detail-header h2 { margin: 0 0 4px 0; font-size: 22px; }
.detail-header .sub { color: var(--gray-600); font-size: 14px; }
.detail-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; margin: 18px 0; }
.detail-meta-grid .meta-item .k { font-size: 11.5px; color: var(--gray-600); text-transform: uppercase; letter-spacing: .03em; }
.detail-meta-grid .meta-item .v { font-size: 15px; font-weight: 600; margin-top: 2px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  padding: 14px 0;
  border-bottom: 1px solid var(--gray-100);
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
}
.timeline li:last-child { border-bottom: none; }
.timeline .t-date { font-size: 12.5px; color: var(--gray-600); font-weight: 600; }
.timeline .t-type { display:inline-block; margin-top:4px; }
.timeline .t-note { font-size: 14px; }
.timeline .t-next { margin-top: 6px; font-size: 12.5px; color: var(--gray-600); }
.timeline .t-followup { color: var(--orange); font-weight: 600; }

.section-title { font-size: 15px; font-weight: 700; margin: 28px 0 12px 0; color: var(--navy); }

.empty-state { padding: 40px 20px; text-align: center; color: var(--gray-600); }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
}
.login-box { width: 360px; background: #fff; border-radius: 10px; padding: 32px; box-shadow: var(--shadow); }
.login-box h1 { font-size: 18px; margin: 0 0 4px 0; }
.login-box .sub { font-size: 13px; color: var(--gray-600); margin-bottom: 20px; }

.text-muted { color: var(--gray-600); }
.mt-0{margin-top:0} .mb-0{margin-bottom:0}
