:root {
  --bg: #f5f8f8;
  --surface: #ffffff;
  --surface-2: #eef5f4;
  --primary: #0c5d5b;
  --primary-2: #147874;
  --primary-3: #dff1ee;
  --ink: #16333c;
  --muted: #6a7d83;
  --border: #d9e4e3;
  --shadow: 0 18px 45px rgba(22, 51, 60, .08);
  --danger: #dc4a53;
  --warning: #e6a62c;
  --success: #1f9d68;
  --info: #2b7fc0;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.eyebrow { display:block; font-size: 11px; letter-spacing: .12em; font-weight: 700; color: var(--primary-2); margin-bottom: 6px; }

.login-shell { min-height: 100vh; display:grid; grid-template-columns: minmax(420px, 520px) 1fr; background: linear-gradient(90deg,#f7fbfa 0 43%,#e8f3f1 43%); }
.login-card { background:#fff; padding:52px; display:flex; flex-direction:column; justify-content:center; box-shadow: 18px 0 60px rgba(20,70,70,.08); z-index:2; }
.brand-lockup, .sidebar-brand { display:flex; align-items:center; gap:14px; }
.brand-mark { width:56px; height:56px; border:2px solid var(--primary); border-radius:18px; display:grid; place-items:center; color:var(--primary); font-size:32px; transform:rotate(-3deg); }
.brand-mark.small { width:44px; height:44px; border-color:#fff; color:#fff; font-size:24px; border-radius:14px; }
.brand-lockup h1 { font-family:"Libre Baskerville", serif; margin:0; font-size:25px; }
.brand-lockup p { margin:5px 0 0; color:var(--muted); }
.login-copy { margin:54px 0 24px; }
.login-copy h2 { font-size:30px; margin:0 0 10px; }
.login-copy p { margin:0; color:var(--muted); line-height:1.6; }
.form-stack { display:grid; gap:16px; }
label { display:grid; gap:7px; font-size:13px; font-weight:600; color:#36515a; }
input, select, textarea { border:1px solid var(--border); border-radius:12px; padding:12px 13px; background:#fff; color:var(--ink); outline:none; transition:.2s; }
input:focus, select:focus, textarea:focus { border-color:#69aaa7; box-shadow:0 0 0 3px rgba(20,120,116,.09); }
.btn { border:0; border-radius:12px; padding:11px 16px; font-weight:700; }
.btn-lg { padding:14px 18px; }
.btn-primary { background:var(--primary); color:#fff; }
.btn-primary:hover { background:#084e4d; }
.btn-secondary { background:var(--primary-3); color:var(--primary); }
.btn-ghost { background:#f1f5f4; color:#4e666d; }
.demo-box { margin-top:18px; background:#f5f8f8; border:1px solid var(--border); padding:14px; border-radius:12px; display:grid; gap:5px; font-size:12px; color:var(--muted); }
.demo-box strong { color:var(--ink); }
.login-visual { padding:70px; display:flex; align-items:center; justify-content:center; position:relative; overflow:hidden; }
.login-visual::before, .login-visual::after { content:""; position:absolute; border-radius:999px; background:rgba(12,93,91,.08); }
.login-visual::before { width:420px; height:420px; top:-100px; right:-80px; }
.login-visual::after { width:260px; height:260px; bottom:-70px; left:80px; }
.visual-card { max-width:640px; background:rgba(255,255,255,.75); backdrop-filter:blur(10px); border:1px solid rgba(255,255,255,.9); padding:46px; border-radius:28px; box-shadow:var(--shadow); position:relative; z-index:1; }
.visual-card h2 { font-family:"Libre Baskerville", serif; font-size:42px; line-height:1.25; margin:10px 0 16px; }
.visual-card p { color:#567078; line-height:1.7; font-size:17px; }
.visual-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-top:30px; }
.visual-stats div { background:#fff; border:1px solid var(--border); border-radius:18px; padding:20px; display:grid; gap:4px; }
.visual-stats strong { font-size:25px; color:var(--primary); }
.visual-stats span { font-size:12px; color:var(--muted); }

.system-shell { min-height:100vh; display:grid; grid-template-columns:240px 1fr; }
.sidebar { background:linear-gradient(180deg,#0c5b59,#0b4e4d); color:#fff; padding:26px 18px; min-height:100vh; position:sticky; top:0; height:100vh; display:flex; flex-direction:column; }
.sidebar-brand { padding:0 10px 24px; }
.sidebar-brand strong { font-size:16px; line-height:1.15; display:block; }
.sidebar-brand span { display:block; color:#b9d8d6; font-size:12px; margin-top:4px; }
.sidebar-nav { display:grid; gap:7px; }
.nav-btn { width:100%; border:0; background:transparent; color:#dceeed; border-radius:11px; text-align:left; padding:11px 12px; display:flex; align-items:center; gap:10px; font-size:14px; }
.nav-btn:hover, .nav-btn.active { background:rgba(255,255,255,.11); color:#fff; }
.nav-icon { width:22px; text-align:center; }
.sidebar-footer { margin-top:auto; padding:20px 10px 8px; font-family:"Libre Baskerville",serif; font-size:16px; line-height:1.5; color:#c8e2df; }
.main-content { min-width:0; padding:24px 28px 40px; }
.topbar { display:flex; justify-content:space-between; align-items:center; gap:20px; margin-bottom:24px; }
.topbar h1 { margin:0; font-family:"Libre Baskerville",serif; font-size:30px; }
.topbar-actions { display:flex; align-items:center; gap:12px; }
.period-control { display:flex; align-items:center; gap:10px; background:#fff; border:1px solid var(--border); border-radius:12px; padding:6px 8px 6px 12px; font-size:11px; color:var(--muted); }
.period-control input { border:0; padding:6px; min-width:145px; }
.icon-btn { border:1px solid var(--border); background:#fff; width:40px; height:40px; border-radius:12px; color:var(--ink); display:grid; place-items:center; font-size:18px; }
.user-chip { display:flex; gap:10px; align-items:center; background:#fff; border:1px solid var(--border); padding:6px 10px 6px 7px; border-radius:14px; }
.avatar { width:34px; height:34px; border-radius:50%; background:#cfe5e3; color:var(--primary); display:grid; place-items:center; font-weight:800; font-size:12px; }
.user-chip strong { display:block; font-size:13px; }
.user-chip span { display:block; font-size:11px; color:var(--muted); margin-top:2px; }

.stats-grid { display:grid; grid-template-columns:repeat(5,minmax(150px,1fr)); gap:14px; margin-bottom:18px; }
.stats-grid.doctor { grid-template-columns:repeat(4,minmax(160px,1fr)); }
.stat-card { background:#fff; border:1px solid var(--border); border-radius:18px; padding:18px; min-height:116px; box-shadow:0 10px 25px rgba(19,54,60,.04); }
.stat-card.tint-green { background:linear-gradient(145deg,#effaf6,#fff); }
.stat-card.tint-blue { background:linear-gradient(145deg,#eff7fb,#fff); }
.stat-card.tint-purple { background:linear-gradient(145deg,#f4f1fb,#fff); }
.stat-card.tint-gold { background:linear-gradient(145deg,#fbf6ea,#fff); }
.stat-card.tint-red { background:linear-gradient(145deg,#fff1f2,#fff); }
.stat-label { font-size:11px; font-weight:800; letter-spacing:.03em; color:#4f6970; }
.stat-value { font-size:30px; font-weight:800; margin:10px 0 4px; color:var(--ink); }
.stat-note { font-size:11px; color:var(--muted); }

.panel { background:#fff; border:1px solid var(--border); border-radius:18px; box-shadow:0 10px 28px rgba(19,54,60,.04); overflow:hidden; }
.panel + .panel { margin-top:16px; }
.panel-header { padding:18px 18px 14px; display:flex; justify-content:space-between; align-items:center; gap:12px; }
.panel-header h2 { margin:0; font-size:18px; }
.panel-header p { margin:4px 0 0; font-size:12px; color:var(--muted); }
.panel-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.search-input { min-width:280px; }
.table-wrap { overflow:auto; }
table { width:100%; border-collapse:collapse; min-width:1050px; }
th { background:#0f6764; color:#fff; text-align:left; font-size:11px; letter-spacing:.02em; padding:11px 12px; position:sticky; top:0; }
td { padding:12px; border-top:1px solid #e7eeee; font-size:12px; vertical-align:top; }
tbody tr:hover { background:#f8fbfb; }
.muted { color:var(--muted); }
.status { display:inline-flex; align-items:center; gap:6px; border-radius:999px; padding:6px 9px; font-size:10px; font-weight:800; white-space:nowrap; }
.status::before { content:""; width:7px; height:7px; border-radius:50%; background:currentColor; }
.status-confirmada { background:#dff5e8; color:#168456; }
.status-aguardando { background:#fff0ca; color:#c98a0d; }
.status-pendente { background:#ffe0e2; color:#c63e48; }
.status-realizada { background:#deeffb; color:#267ab4; }
.status-cancelada { background:#e7ecef; color:#6b7e87; }
.status-remarcar { background:#ffe5da; color:#d66a3e; }
.row-actions { display:flex; gap:6px; }
.mini-btn { border:1px solid var(--border); background:#fff; border-radius:9px; padding:7px 9px; font-size:11px; color:#456068; }
.mini-btn.danger { color:#c23c48; }
.table-footer { padding:12px 18px 16px; color:var(--muted); font-size:11px; display:flex; justify-content:space-between; align-items:center; }

.bottom-grid { display:grid; grid-template-columns:1.1fr 1fr 1fr; gap:14px; margin-top:16px; }
.mini-panel { background:#fff; border:1px solid var(--border); border-radius:16px; padding:16px; }
.mini-panel h3 { margin:0 0 14px; font-size:15px; }
.list { display:grid; gap:10px; }
.list-item { border:1px solid #e2eceb; border-radius:12px; padding:12px; display:flex; justify-content:space-between; gap:12px; }
.list-item strong { display:block; font-size:12px; }
.list-item span { display:block; font-size:11px; color:var(--muted); margin-top:3px; }
.filters { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.filters label { font-size:11px; }
.filters select { padding:9px 10px; }
.legend { display:grid; gap:8px; }
.legend-row { display:flex; align-items:center; gap:9px; font-size:11px; color:#536a72; }
.legend-dot { width:10px; height:10px; border-radius:50%; }

.doctor-hero { background:linear-gradient(135deg,#f6fbfa,#e9f4f2); border:1px solid var(--border); border-radius:20px; padding:24px; margin-bottom:16px; display:flex; justify-content:space-between; gap:20px; align-items:center; }
.doctor-hero h2 { font-family:"Libre Baskerville",serif; margin:0 0 8px; font-size:26px; }
.doctor-hero p { margin:0; color:var(--muted); line-height:1.5; }
.hero-badge { background:#fff; border:1px solid var(--border); padding:12px 16px; border-radius:14px; font-size:12px; color:var(--primary); font-weight:800; }
.doctor-layout { display:grid; grid-template-columns:minmax(0,1fr) 300px; gap:16px; }
.side-stack { display:grid; gap:14px; align-content:start; }
.calendar-card { background:#fff; border:1px solid var(--border); border-radius:16px; padding:16px; }
.calendar-row { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; text-align:center; font-size:10px; color:var(--muted); }
.calendar-row.days { margin-top:10px; color:var(--ink); font-weight:600; }
.calendar-row span { padding:6px 0; border-radius:8px; }
.calendar-row .active { background:var(--primary); color:#fff; }

.modal { border:0; padding:0; border-radius:20px; width:min(760px,calc(100vw - 28px)); box-shadow:0 30px 90px rgba(11,53,58,.22); }
.modal::backdrop { background:rgba(17,45,49,.35); backdrop-filter:blur(2px); }
.modal-card { padding:0; }
.modal-header { padding:20px 22px; border-bottom:1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.modal-header h2 { margin:0; }
.form-grid { display:grid; gap:14px; padding:20px 22px; }
.two-col { grid-template-columns:1fr 1fr; }
.span-2 { grid-column:span 2; }
.modal-actions { padding:16px 22px 22px; display:flex; justify-content:flex-end; gap:10px; }
.empty-state { padding:48px 20px; text-align:center; color:var(--muted); }
.empty-state strong { display:block; color:var(--ink); margin-bottom:6px; }

@media (max-width: 1100px) {
  .stats-grid, .stats-grid.doctor { grid-template-columns:repeat(2,1fr); }
  .bottom-grid { grid-template-columns:1fr; }
  .doctor-layout { grid-template-columns:1fr; }
  .side-stack { grid-template-columns:repeat(3,1fr); }
}
@media (max-width: 860px) {
  .login-shell { grid-template-columns:1fr; background:#f6fbfa; }
  .login-visual { display:none; }
  .system-shell { grid-template-columns:1fr; }
  .sidebar { position:relative; height:auto; min-height:0; padding:14px; }
  .sidebar-brand { padding-bottom:12px; }
  .sidebar-nav { display:flex; overflow:auto; }
  .nav-btn { white-space:nowrap; width:auto; }
  .sidebar-footer { display:none; }
  .main-content { padding:18px; }
  .topbar { align-items:flex-start; flex-direction:column; }
  .topbar-actions { width:100%; flex-wrap:wrap; }
  .user-chip { margin-left:auto; }
  .side-stack { grid-template-columns:1fr; }
}
@media (max-width: 560px) {
  .login-card { padding:28px 22px; }
  .stats-grid, .stats-grid.doctor { grid-template-columns:1fr; }
  .panel-header { align-items:flex-start; flex-direction:column; }
  .panel-actions { width:100%; }
  .search-input { min-width:0; width:100%; }
  .two-col { grid-template-columns:1fr; }
  .span-2 { grid-column:span 1; }
  .filters { grid-template-columns:1fr; }
  .period-control { width:100%; justify-content:space-between; }
}

@media print {
  .sidebar, .topbar-actions, .panel-actions, .row-actions, .side-stack, .btn, .icon-btn { display:none !important; }
  .system-shell { display:block; }
  .main-content { padding:0; }
  .panel, .stat-card, .doctor-hero { box-shadow:none; break-inside:avoid; }
  body { background:#fff; }
  .topbar { margin-bottom:12px; }
  .topbar h1 { font-size:24px; }
}

/* CRUD modules */
.report-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
@media(max-width:900px){.report-grid{grid-template-columns:1fr}}
