:root {
  --ink: #17211d;
  --muted: #64706a;
  --paper: #f5f6f2;
  --surface: #ffffff;
  --line: #dfe4de;
  --brand: #174d3c;
  --brand-dark: #10382d;
  --accent: #c8a763;
  --danger: #8d2b2b;
  --warning: #7a5b12;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; }
button, input { font: inherit; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; padding: 12px max(24px, calc((100vw - 1180px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: var(--brand); color: white; font-family: Georgia, serif; font-weight: 700; }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 2px; color: var(--muted); }
.topbar-actions, .main-nav { display: flex; align-items: center; gap: 10px; }
.topbar-actions { gap: 18px; }
.main-nav a { padding: 9px 11px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 750; }
.main-nav a:hover, .main-nav a[aria-current="page"] { color: var(--brand); background: #edf2ee; }
.page { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 48px 0 64px; }
.footer { padding: 24px; text-align: center; color: var(--muted); font-size: .86rem; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.1rem, 4vw, 3.5rem); line-height: 1.05; letter-spacing: -.035em; }
h2 { margin-bottom: 8px; font-size: 1.18rem; }
.lead { color: var(--muted); font-size: 1.08rem; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 8px; color: var(--brand); font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 42px; padding: 10px 18px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; text-decoration: none; font-weight: 750; }
.button-primary { color: white; background: var(--brand); }
.button-primary:hover { background: var(--brand-dark); }
.button-quiet { color: var(--brand); background: #edf2ee; }
.logout-form { margin: 0; }
.notice { margin: 0 0 18px; padding: 12px 14px; border-radius: 9px; font-size: .92rem; }
.notice-error { color: var(--danger); background: #f9e9e7; border: 1px solid #efd0cc; }
.notice-warning { color: var(--warning); background: #fff6dc; border: 1px solid #eedda9; }
.login-shell { min-height: calc(100vh - 230px); display: grid; grid-template-columns: 1.1fr .9fr; gap: 70px; align-items: center; }
.login-intro { max-width: 620px; }
.login-intro p:last-child { max-width: 520px; color: var(--muted); font-size: 1.05rem; line-height: 1.65; }
.login-card { width: 100%; max-width: 440px; justify-self: end; padding: 34px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 18px 50px rgba(31, 54, 43, .08); }
.form-stack { display: grid; gap: 16px; }
.form-stack label { display: grid; gap: 7px; color: #334139; font-size: .89rem; font-weight: 700; }
input { width: 100%; min-height: 46px; padding: 10px 12px; color: var(--ink); background: white; border: 1px solid #cfd7d1; border-radius: 9px; }
input:focus { outline: 3px solid rgba(23, 77, 60, .16); border-color: var(--brand); }
.hero-row, .page-heading, .practice-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 34px; }
.search-form { display: grid; grid-template-columns: minmax(220px, 330px) auto; gap: 9px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 24px; }
.metrics-compact { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.metric { position: relative; overflow: hidden; padding: 22px; }
.metric-accent::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent); }
.metric-danger::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--danger); }
.metric-danger strong { color: var(--danger); }
.metric span, .metric small { display: block; color: var(--muted); }
.metric strong { display: block; margin: 8px 0 4px; color: var(--brand); font-family: Georgia, serif; font-size: 2.35rem; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; }
.panel { padding: 24px; }
.panel-main { padding: 0; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 22px 24px 14px; }
.panel-heading p, .panel-heading h2 { margin-bottom: 0; }
.practice-list { display: grid; }
.practice-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 130px 24px; gap: 16px; align-items: center; min-height: 76px; padding: 15px 24px; border-top: 1px solid var(--line); text-decoration: none; }
.practice-row:hover { background: #f8faf8; }
.practice-code { color: var(--brand); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; font-weight: 750; }
.practice-name strong, .practice-name small { display: block; }
.practice-name small { margin-top: 5px; color: var(--muted); }
.practice-status { color: var(--muted); font-size: .82rem; text-transform: capitalize; }
.side-stack { display: grid; gap: 20px; align-content: start; }
.compact p:last-child { margin-bottom: 0; color: var(--muted); }
.side-number { display: block; margin-bottom: 4px; color: var(--brand); font-family: Georgia, serif; font-size: 2.4rem; }
.status-pill { display: inline-flex; padding: 7px 10px; border-radius: 999px; color: var(--brand); background: #e6f0ea; font-size: .74rem; font-weight: 800; text-transform: uppercase; }
.status-muted { color: #645d4a; background: #f0eee7; }
.status-danger { color: var(--danger); background: #f9e9e7; }
.status-large { padding: 10px 14px; }
.priority-pill { display: inline-flex; width: max-content; padding: 6px 9px; border-radius: 999px; font-size: .72rem; font-weight: 850; text-transform: uppercase; }
.priority-urgent { color: #7d1e1e; background: #f8dddd; }
.priority-attention { color: #72540c; background: #fff0c6; }
.priority-normal { color: #476056; background: #e9efeb; }
.hero-status { display: grid; justify-items: end; gap: 8px; }
.priority-notice { margin-top: -18px; }
.priority-notice-urgent { color: var(--danger); background: #f9e9e7; border: 1px solid #efd0cc; }
.priority-notice-attention { color: var(--warning); background: #fff6dc; border: 1px solid #eedda9; }
.text-link { display: inline-block; margin-top: 8px; color: var(--brand); font-size: .88rem; font-weight: 750; }
.recent-panel, .task-section, .history-panel { margin-top: 20px; }
.integration-note { margin: 14px 2px 0; color: var(--muted); font-size: .83rem; text-align: right; }
.breadcrumb { display: flex; gap: 9px; margin-bottom: 28px; color: var(--muted); font-size: .88rem; }
.breadcrumb a { color: var(--brand); }
.practice-hero { align-items: center; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-card { color: white; background: var(--brand); border-color: var(--brand); }
.detail-card .eyebrow, .detail-card p { color: #d7e7df; }
.full-span { grid-column: 1 / -1; }
.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 14px 0 0; }
.facts div { padding: 14px 0; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); font-size: .79rem; }
.facts dd { margin: 5px 0 0; font-weight: 700; }
.placeholder-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0 24px 24px; }
.placeholder-grid div, .placeholder-grid a { min-height: 100px; padding: 17px; border-radius: 10px; background: #f5f7f4; text-decoration: none; }
.placeholder-grid a:hover { background: #eaf1ec; }
.placeholder-grid strong, .placeholder-grid span { display: block; }
.placeholder-grid span { margin-top: 8px; color: var(--muted); font-size: .88rem; }
.agenda-grid, .today-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.panel-list { padding: 0; overflow: hidden; }
.event-list, .task-list { display: grid; }
.event-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) 18px; gap: 14px; align-items: center; padding: 17px 20px; border-top: 1px solid var(--line); text-decoration: none; }
.event-row:hover { background: #f8faf8; }
.event-row.is-cancelled { opacity: .58; text-decoration: line-through; }
.event-date { display: grid; gap: 3px; justify-items: center; color: var(--brand); }
.event-date strong { font-family: Georgia, serif; font-size: 1.16rem; }
.event-date small, .event-body small { color: var(--muted); }
.event-body, .event-body > strong, .event-body > small { display: block; min-width: 0; }
.event-body > strong { margin: 7px 0 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .76rem; overflow-wrap: anywhere; }
.event-title { display: flex; gap: 6px; align-items: center; }
.type-pill, .source-pill { display: inline-flex; padding: 4px 7px; border-radius: 999px; font-size: .65rem; font-weight: 850; text-transform: uppercase; }
.type-udienza { color: #164936; background: #dfeee6; }
.type-scadenza { color: #73550b; background: #fff0c5; }
.type-prescrizione { color: #7d1e1e; background: #f8dddd; }
.source-pill { color: #3d526b; background: #e8eef5; }
.history-panel { padding: 0; overflow: hidden; }
.history-panel summary { padding: 19px 22px; color: var(--brand); cursor: pointer; font-weight: 800; }
.pdua-notice, .write-notice { margin-top: 20px; margin-bottom: 0; }
.task-overdue { border-color: #e5b7b2; }
.task-row { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 17px 20px; border-top: 1px solid var(--line); }
.task-row.priority-alta { box-shadow: inset 3px 0 var(--danger); }
.task-row.priority-media { box-shadow: inset 3px 0 var(--accent); }
.task-check { color: var(--brand); font-size: 1.25rem; line-height: 1.1; }
.task-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.task-heading strong { line-height: 1.35; }
.task-priority { color: var(--muted); font-size: .68rem; font-weight: 850; text-transform: uppercase; }
.task-body p { margin: 7px 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.task-body small { color: var(--muted); }
.task-body small a { color: var(--brand); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 750; }
.count-badge { display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 999px; color: var(--brand); background: #e6f0ea; font-weight: 850; }
.count-danger { color: var(--danger); background: #f9e9e7; }
.empty-state { padding: 55px 24px; text-align: center; color: var(--muted); }
.standalone { min-height: 55vh; display: grid; place-content: center; justify-items: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
@media (max-width: 860px) {
  .page { width: min(100% - 28px, 700px); padding-top: 30px; }
  .login-shell { grid-template-columns: 1fr; gap: 30px; }
  .login-card { justify-self: stretch; max-width: none; }
  .hero-row, .page-heading { align-items: stretch; flex-direction: column; }
  .search-form { grid-template-columns: 1fr auto; width: 100%; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .content-grid { grid-template-columns: 1fr; }
  .agenda-grid, .today-grid { grid-template-columns: 1fr; }
  .side-stack { grid-template-columns: 1fr 1fr; }
  .practice-row { grid-template-columns: 1fr 24px; }
  .practice-row .practice-code, .practice-row .practice-status { grid-column: 1; }
  .practice-row .practice-name { grid-column: 1; }
  .practice-row > span:last-child { grid-column: 2; grid-row: 1 / span 3; }
}
@media (max-width: 560px) {
  .topbar { min-height: 66px; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .brand small { display: none; }
  .topbar-actions { width: 100%; justify-content: space-between; gap: 8px; }
  .main-nav { gap: 2px; }
  .main-nav a { padding: 8px; font-size: .82rem; }
  .button-quiet { min-height: 38px; padding: 8px 12px; }
  .page { width: min(100% - 20px, 520px); }
  .metrics, .metrics-compact, .side-stack, .detail-grid, .placeholder-grid, .facts { grid-template-columns: 1fr; }
  .full-span { grid-column: 1; }
  .search-form { grid-template-columns: 1fr; }
  .practice-hero { align-items: flex-start; flex-direction: column; }
  .hero-status { justify-items: start; }
  .login-card { padding: 24px; }
}
