/* ==========================================================================
   Planifica — EV & ET
   Design system e estilos da aplicação
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;

  --paper:        #eef3fb;
  --paper-deep:   #e2eaf7;
  --surface:      #ffffff;
  --surface-2:    #f6f9fe;
  --surface-3:    #edf2fb;

  --ink:          #0f1c2e;
  --ink-2:        #33445e;
  --muted:        #62718a;
  --muted-2:      #8492a8;

  --line:         #dce5f2;
  --line-strong:  #c3d2e6;

  --brand:        #015bcf;
  --brand-dark:   #0149a8;
  --brand-deep:   #0a1f3d;
  --brand-soft:   #e3eefc;
  --brand-softer: #f0f6fe;

  --accent:       #e0a200;
  --accent-dark:  #b57f00;
  --accent-soft:  #fdf3d7;

  --ok:           #1f7a55;
  --ok-soft:      #e5f4ec;
  --warn:         #9a6a12;
  --warn-soft:    #fbf1d9;
  --danger:       #a63c33;
  --danger-soft:  #f9e8e5;
  --info:         #1f5f9e;
  --info-soft:    #e7f0fb;

  --sidebar-bg:   linear-gradient(180deg, #071b36 0%, #0a2447 100%);
  --topbar-bg:    rgba(238, 243, 251, .86);
  --toast-bg:     #0a1f3d;

  --radius:       12px;
  --radius-sm:    8px;
  --radius-lg:    18px;

  --shadow-xs: 0 1px 2px rgba(10, 31, 61, .06);
  --shadow-sm: 0 1px 2px rgba(10, 31, 61, .06), 0 6px 16px -10px rgba(10, 31, 61, .22);
  --shadow-md: 0 2px 4px rgba(10, 31, 61, .06), 0 18px 40px -22px rgba(10, 31, 61, .34);
  --shadow-lg: 0 30px 80px -30px rgba(3, 12, 26, .5);

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;

  --sidebar-w: 236px;
  --topbar-h: 64px;
  --ease: cubic-bezier(.2, .7, .3, 1);
}

html[data-theme="escuro"] {
  color-scheme: dark;

  --paper:        #08111f;
  --paper-deep:   #0a1627;
  --surface:      #0f1b2d;
  --surface-2:    #13223a;
  --surface-3:    #172a45;

  --ink:          #e8f0fb;
  --ink-2:        #c2d2e8;
  --muted:        #8fa2bd;
  --muted-2:      #7286a3;

  --line:         #22344f;
  --line-strong:  #304665;

  --brand:        #4f9dff;
  --brand-dark:   #2f83ef;
  --brand-deep:   #06101f;
  --brand-soft:   #15335c;
  --brand-softer: #102745;

  --accent:       #f0b429;
  --accent-dark:  #d99a00;
  --accent-soft:  #3a2c0d;

  --ok:           #5cc99a;
  --ok-soft:      #0f3326;
  --warn:         #e6b34d;
  --warn-soft:    #3a2c0d;
  --danger:       #ff8a80;
  --danger-soft:  #3a1b1b;
  --info:         #7bb8ff;
  --info-soft:    #122b47;

  --topbar-bg:    rgba(8, 17, 31, .82);
  --toast-bg:     #1b2d48;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .32);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .32), 0 6px 16px -10px rgba(0, 0, 0, .6);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .36), 0 18px 40px -22px rgba(0, 0, 0, .7);
  --shadow-lg: 0 30px 80px -30px rgba(0, 0, 0, .82);
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
ul, ol { margin: 0; padding: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
::selection { background: var(--brand-soft); color: var(--brand-deep); }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: fixed; top: -60px; left: 16px; z-index: 200;
  background: var(--brand-deep); color: #fff; padding: 10px 16px; border-radius: 8px;
}
.skip-link:focus { top: 12px; }

/* ---------- 3. Layout ---------- */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

.app-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 400px at 85% -10%, rgba(224, 162, 0, .07), transparent 60%),
    radial-gradient(700px 380px at 10% 110%, rgba(1, 91, 207, .07), transparent 60%),
    var(--paper);
}

.view {
  flex: 1;
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 34px 72px;
  animation: view-in .32s var(--ease) both;
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.boot {
  position: fixed; inset: 0; display: grid; place-content: center; gap: 14px;
  text-align: center; color: var(--muted);
}
.boot-mark {
  width: 54px; height: 54px; margin: 0 auto; border-radius: 15px;
  background: #fff; color: var(--brand-deep); object-fit: cover;
  display: grid; place-items: center; font-weight: 650; font-size: 26px;
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: scale(.94); opacity: .7; } }

/* ---------- 4. Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 40;
  background: var(--sidebar-bg);
  color: #e8f0fb;
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.brand {
  display: flex; align-items: center; gap: 9px;
  padding: 14px 14px 12px;
}
.brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: #fff; color: var(--brand-deep); object-fit: cover;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px; letter-spacing: -.04em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .06);
}
.brand-name { font-size: 13.5px; font-weight: 650; letter-spacing: -.01em; line-height: 1.2; }
.brand-sub { font-size: 9.5px; color: #8fb0d8; letter-spacing: .1em; text-transform: uppercase; margin-top: 1px; }

.nav { padding: 4px 8px; overflow-y: auto; flex: 1; }
.nav-group-label {
  font-size: 9.5px; letter-spacing: .13em; text-transform: uppercase;
  color: #7f9cc4; padding: 13px 9px 5px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; margin: 0;
  border-radius: 7px; color: #c3d5ee;
  font-size: 12.5px; font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item.is-active { background: #eaf3ff; color: #071b36; font-weight: 600; box-shadow: var(--shadow-xs); }
.nav-item.is-active .nav-icon { color: var(--accent); }
.nav-icon { width: 16px; height: 16px; flex: none; color: #7f9cc4; }
.nav-item > svg { width: 16px; height: 16px; flex: none; color: #7f9cc4; }
.nav-item.is-active > svg { color: var(--accent); }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 600;
  background: rgba(255, 255, 255, .1); color: #d7e2dc;
  padding: 0 6px; border-radius: 20px; font-variant-numeric: tabular-nums;
}
.nav-item.is-active .nav-badge { background: #d7e6fa; color: #27405f; }

.sidebar-foot {
  padding: 10px 13px 12px; border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 10.5px; color: #7f9cc4; line-height: 1.45;
}
.sync-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #5cc99a; margin-right: 6px; vertical-align: 1px;
}
.sync-dot.is-off { background: #7286a3; }
.sync-dot.is-warn { background: #e6b34d; }

/* ---------- 5. Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 34px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted); min-width: 0;
}
.topbar-crumbs a { color: var(--muted); text-decoration: none; }
.topbar-crumbs a:hover { color: var(--brand); text-decoration: none; }
.brand:hover { text-decoration: none; }
.crumb-sep { color: var(--line-strong); }
.crumb-current { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-spacer { flex: 1; }

.year-select {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 5px 8px 5px 11px;
  box-shadow: var(--shadow-xs);
}
.year-select label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.year-select select {
  border: 0; background: transparent; font-size: 13px; font-weight: 600;
  padding: 2px 18px 2px 0; cursor: pointer; color: var(--ink);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236d7874' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0 center;
}
.year-select select option {
  background: var(--surface);
  color: var(--ink);
}
.topbar-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 9px;
  color: var(--ink-2); box-shadow: var(--shadow-xs);
}
.topbar-btn:hover { border-color: var(--line-strong); color: var(--brand); }

.menu-toggle { display: none; }

/* ---------- 6. Page / typography ---------- */
.page-head {
  display: flex; align-items: flex-end; gap: 20px;
  margin-bottom: 26px; flex-wrap: wrap;
}
.page-head-main { min-width: 0; flex: 1; }
.eyebrow {
  font-size: 10.5px; font-weight: 650; letter-spacing: .13em;
  text-transform: uppercase; color: var(--accent-dark);
  margin-bottom: 6px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 29px; line-height: 1.15; font-weight: 650;
  letter-spacing: -.025em; color: var(--ink);
}
.page-sub { margin-top: 7px; color: var(--muted); font-size: 13.5px; max-width: 74ch; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

.section-head {
  display: flex; align-items: center; gap: 14px;
  margin: 30px 0 13px;
}
.section-head h2 { font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.section-head .section-sub { font-size: 12.5px; color: var(--muted); }
.section-head .spacer { flex: 1; }

.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.serif { font-family: Georgia, "Times New Roman", serif; }

/* ---------- 7. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2);
  font-size: 13px; font-weight: 600; letter-spacing: -.005em;
  box-shadow: var(--shadow-xs);
  transition: background .14s, border-color .14s, color .14s, transform .06s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--ink); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #ffffff;
  box-shadow: 0 1px 2px rgba(1, 73, 168, .28), inset 0 1px 0 rgba(255, 255, 255, .14);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #241a00; }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-danger { background: var(--danger-soft); border-color: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); filter: brightness(.97); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-icon { width: 30px; height: 30px; padding: 0; border-radius: 7px; }
.btn-icon svg { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn-tr { min-width: 36px; font-size: 11px; letter-spacing: .04em; }
.btn-tr.is-active {
  background: var(--brand-soft); border-color: var(--brand-soft); color: var(--brand-dark);
}
.btn-tr.is-active:hover { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.btn[disabled], .btn:disabled { opacity: .5; pointer-events: none; }

.link-btn {
  border: 0; background: none; padding: 0; color: var(--brand);
  font-weight: 600; font-size: 12.5px; display: inline-flex; align-items: center; gap: 4px;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.link-btn svg { width: 14px; height: 14px; }

/* ---------- 8. Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  font-size: 11.5px; font-weight: 650; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-2);
  display: flex; align-items: center; gap: 6px;
}
.field-label .req { color: var(--accent); font-size: 13px; line-height: 0; }
.field-help { font-size: 11.5px; color: var(--muted-2); line-height: 1.45; }
.field-error { font-size: 11.5px; color: var(--danger); font-weight: 600; }

.input, .select, .textarea {
  width: 100%; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px;
  padding: 8px 11px; font-size: 13.5px; color: var(--ink);
  transition: border-color .14s, box-shadow .14s;
  box-shadow: inset 0 1px 1px rgba(23, 38, 33, .02);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(1, 91, 207, .14);
}
.input.is-invalid, .textarea.is-invalid, .select.is-invalid { border-color: var(--danger); }
.field.is-invalid > .field-label { color: var(--danger); }
.field.is-invalid .pick-list,
.field.is-invalid .multi-list,
.field.is-invalid .date-field .input {
  outline: 1px solid var(--danger);
  outline-offset: 2px;
  border-radius: 8px;
}
.field.is-invalid .pick-list { background: rgba(190, 30, 45, .05); padding: 6px; }
.textarea { resize: vertical; min-height: 84px; line-height: 1.5; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236d7874' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.input[type="number"] { font-variant-numeric: tabular-nums; }
.input-sm { padding: 5px 8px; font-size: 12.5px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.span-2 { grid-column: span 2; }
.span-1 { grid-column: span 1; }
.form-section { margin-bottom: 30px; }
.form-section-head {
  display: flex; align-items: baseline; gap: 10px;
  padding-bottom: 9px; margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.form-section-head h3 { font-size: 13.5px; font-weight: 650; letter-spacing: .01em; }
.form-section-head .hint { font-size: 12px; color: var(--muted); }

.check-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px; max-height: 330px; overflow: auto;
  border: 1px solid var(--line); border-radius: 9px; padding: 10px;
  background: var(--surface-2);
}
.check-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 7px 9px; border-radius: 7px; font-size: 12.5px;
  border: 1px solid transparent; cursor: pointer; line-height: 1.4;
  background: var(--surface);
}
.check-item:hover { border-color: var(--line); }
.check-item input { margin: 3px 0 0; accent-color: var(--brand); flex: none; }
.check-item.is-checked { border-color: var(--line-strong); background: var(--brand-softer); }
.check-group-label {
  grid-column: 1 / -1; font-size: 10.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted-2); padding: 8px 4px 2px;
  border-top: 1px solid var(--line); margin-top: 4px;
}
.check-group-label:first-child { border-top: 0; margin-top: 0; }

.switch-row { display: flex; align-items: center; gap: 10px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: var(--line-strong); border-radius: 20px;
  transition: background .16s; cursor: pointer;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: transform .16s; box-shadow: var(--shadow-xs);
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(16px); }

/* ---------- 9. Cards & layout helpers ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 13.5px; font-weight: 650; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; } .mt-4 { margin-top: 28px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }

/* ---------- 10. Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow-xs);
  position: relative; overflow: hidden;
}
.stat-label { font-size: 10.5px; font-weight: 650; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 27px; font-weight: 600; letter-spacing: -.03em; line-height: 1.2; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 14px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.stat-foot { font-size: 11.5px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 5px; }
.stat-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--brand); opacity: .7; }
.stat-accent.is-accent { background: var(--accent); }
.stat-accent.is-warn { background: var(--warn); }
.stat-accent.is-info { background: var(--info); }

/* ---------- 11. Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: 20px;
  font-size: 11px; font-weight: 650; letter-spacing: .01em;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid transparent; white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge-accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-outline { background: transparent; border-color: var(--line-strong); color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 7px;
  background: var(--surface-3); border: 1px solid var(--line);
  font-size: 12px; color: var(--ink-2);
}
.chip code { font-family: var(--mono); font-size: 10.5px; color: var(--muted); }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 12. Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.table th {
  text-align: left; font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .col-actions { text-align: right; white-space: nowrap; width: 1%; }
.table .row-title { font-weight: 600; color: var(--ink); }
.table .row-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.table td.is-num, .table th.is-num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.is-center, .table td.is-center { text-align: center; }
.table-compact td { padding: 8px 12px; }
.table-compact th { padding: 8px 12px; }
.table-wrap .table tr.is-clickable { cursor: pointer; }

.grade-table td { padding: 4px 6px; }
.grade-table th { padding: 8px 6px; text-align: center; }
.grade-table th.student-col, .grade-table td.student-col { text-align: left; padding-left: 14px; position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 190px; }
.grade-table th.student-col { background: var(--surface-2); z-index: 3; }
.grade-table tbody tr:hover td.student-col { background: var(--surface-2); }
.grade-input, .grade-table .input {
  width: 58px; text-align: center; padding: 6px 4px; font-variant-numeric: tabular-nums;
  border-radius: 6px; font-weight: 600;
}
.grade-input.is-empty { color: var(--muted-2); font-weight: 400; }
.grade-table .avg-cell { font-weight: 650; font-variant-numeric: tabular-nums; }
.grade-table .final-cell {
  background: var(--brand-softer); font-weight: 700; font-size: 14px;
}
.grade-table tfoot td { background: var(--surface-2); font-weight: 600; font-size: 12px; border-top: 1px solid var(--line); }

/* ---------- 13. Tabs ---------- */
.tabs {
  display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}
.tab {
  padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  border: 0; background: none; border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab:focus { text-decoration: none; }
.tab.is-active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tab .count {
  font-size: 10.5px; background: var(--surface-3); padding: 1px 6px;
  border-radius: 20px; color: var(--muted); font-weight: 700;
}
.tab.is-active .count { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- 14. Progress ---------- */
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 6px; transition: width .35s var(--ease); }
.progress.is-accent > span { background: var(--accent); }
.progress.is-warn > span { background: var(--warn); }
.progress-lg { height: 9px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }

/* ---------- 15. Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit;
}
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item-main { min-width: 0; flex: 1; }
.list-item-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-date {
  flex: none; width: 44px; text-align: center; padding: 5px 0;
  background: var(--surface-3); border-radius: 8px; border: 1px solid var(--line);
}
.list-date .d { display: block; font-size: 16px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; }
.list-date .m { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 650; }
.list-date.is-today { background: var(--brand-soft); border-color: var(--line-strong); }
.list-date.is-today .m, .list-date.is-today .d { color: var(--brand-dark); }

/* ---------- 16. Empty states ---------- */
.empty {
  text-align: center; padding: 46px 24px; color: var(--muted);
}
.empty-icon {
  width: 46px; height: 46px; border-radius: 13px; margin: 0 auto 12px;
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted);
  border: 1px solid var(--line);
}
.empty-icon svg { width: 22px; height: 22px; }
.empty h3 { font-size: 14.5px; color: var(--ink); font-weight: 650; margin-bottom: 4px; }
.empty p { font-size: 12.5px; max-width: 46ch; margin: 0 auto 16px; }

/* ---------- 17. Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 14, 30, .56);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
  animation: fade-in .16s ease both;
}
@keyframes fade-in { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: min(86vh, 900px);
  display: flex; flex-direction: column; overflow: hidden;
  animation: modal-in .22s var(--ease) both;
  border: 1px solid var(--line);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal.is-wide { max-width: 780px; }
.modal.is-xl { max-width: 1000px; }
.modal-head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 20px 22px 16px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }
.modal-head p { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.modal-close {
  margin-left: auto; width: 30px; height: 30px; flex: none;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  display: grid; place-items: center; color: var(--muted);
}
.modal-close:hover { background: var(--surface-2); color: var(--ink); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 22px; border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.modal-foot .left { margin-right: auto; }

/* ---------- 18. Toasts ---------- */
.toast-stack {
  position: fixed; right: 22px; bottom: 22px; z-index: 150;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--toast-bg); color: #eef4ff; border-radius: 10px;
  padding: 11px 15px; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md); pointer-events: auto;
  animation: toast-in .25s var(--ease) both;
  max-width: 380px;
}
.toast svg { width: 16px; height: 16px; flex: none; color: #5cc99a; }
.toast.is-error svg { color: #ff8a80; }
.toast.is-out { animation: toast-out .2s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- 19. Specific blocks ---------- */
.hero {
  background: linear-gradient(135deg, #071b36 0%, #0a2b58 70%, #0d3a76 100%);
  color: #eef4ff; border-radius: var(--radius-lg);
  padding: 28px 30px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-md);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -70px;
  width: 240px; height: 240px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(224, 162, 0, .5), transparent 65%);
}
.hero h1 { font-size: 26px; font-weight: 620; letter-spacing: -.025em; }
.hero p { color: #b9cce8; font-size: 13.5px; margin-top: 6px; max-width: 60ch; }
.hero .hero-actions { display: flex; gap: 9px; margin-top: 20px; flex-wrap: wrap; }
.hero .btn { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; box-shadow: none; }
.hero .btn:hover { background: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .3); }
.hero .btn-primary { background: #fff; border-color: #fff; color: #071b36; }
.hero .btn-primary:hover { background: #eaf3ff; border-color: #eaf3ff; color: #071b36; }

.turma-card {
  display: block; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-xs);
  color: inherit; text-decoration: none; transition: border-color .16s, box-shadow .16s, transform .16s;
}
.turma-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); text-decoration: none; }
.turma-card-top { display: flex; align-items: flex-start; gap: 10px; }
.turma-card h3 { font-size: 18px; font-weight: 650; letter-spacing: -.02em; }
.turma-card .disc {
  margin-left: auto; font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  background: var(--brand-soft); color: var(--brand-dark); padding: 3px 8px; border-radius: 6px;
}
.turma-card .disc.is-et { background: var(--accent-soft); color: var(--accent-dark); }
.turma-meta { display: flex; gap: 14px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.turma-meta .m { font-size: 11.5px; color: var(--muted); }
.turma-meta .m b { display: block; font-size: 15px; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px 22px; }
.info-item .k { font-size: 10.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted-2); }
.info-item .v { font-size: 13.5px; margin-top: 2px; }

.ut-row { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.ut-row:last-child { border-bottom: 0; }
.ut-row:hover { background: var(--surface-2); }
.ut-row-main { flex: 1; min-width: 0; }
.ut-row-title { font-size: 13.5px; font-weight: 600; }
.ut-row-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.ut-progress { width: 130px; flex: none; }

.ae-item { padding: 13px 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.ae-item:last-child { border-bottom: 0; }
.ae-code {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  background: var(--surface-3); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 5px; color: var(--muted); flex: none; margin-top: 1px;
}
.ae-text { font-size: 12.5px; line-height: 1.5; flex: 1; }
.ae-actions { display: flex; gap: 2px; opacity: .35; transition: opacity .14s; }
.ae-item:hover .ae-actions { opacity: 1; }
.ae-inactive { opacity: .5; }

.instrument-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 13px 15px; display: flex; flex-direction: column; gap: 8px;
}
.instrument-card .name { font-size: 13px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.instrument-card .meta { font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 10px; }
.instrument-card .acts { margin-left: auto; display: flex; gap: 2px; }

.callout {
  display: flex; gap: 12px; padding: 14px 16px;
  border-radius: 10px; background: var(--info-soft);
  border: 1px solid var(--line); font-size: 12.5px; color: var(--ink-2);
  line-height: 1.5;
}
.callout svg { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--info); }
.callout.is-warn { background: var(--warn-soft); border-color: var(--line); color: var(--ink-2); }
.callout.is-warn svg { color: var(--warn); }
.callout.is-ok { background: var(--ok-soft); border-color: var(--line); color: var(--ink-2); }
.callout.is-ok svg { color: var(--ok); }
.callout.is-danger { background: var(--danger-soft); border-color: var(--line); color: var(--ink-2); }
.callout.is-danger svg { color: var(--danger); }
.callout .callout-title { font-weight: 650; margin-bottom: 2px; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand-dark);
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
}
.avatar.is-accent { background: var(--accent-soft); color: var(--accent-dark); }

.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
  min-width: 190px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-md); padding: 5px;
}
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 8px 10px; border: 0; background: none; border-radius: 6px;
  font-size: 12.5px; font-weight: 500; text-align: left; color: var(--ink-2);
}
.menu-item:hover { background: var(--surface-2); color: var(--ink); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item svg { width: 15px; height: 15px; }
.menu-wrap { position: relative; display: inline-flex; }
.menu[hidden] { display: none; }
.menu.is-floating {
  position: fixed; right: auto; z-index: 400;
  min-width: 200px; max-width: min(320px, calc(100vw - 20px));
}

/* ---------- Campos de data com calendário ---------- */
.date-field { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; }
.date-field .date-input { flex: 1 1 auto; min-width: 0; }
.date-field-btn {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--ink-2); cursor: pointer;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.date-field-btn:hover { background: var(--surface-2); color: var(--brand); border-color: var(--brand); }
.date-field-btn svg { width: 16px; height: 16px; }

.date-pop {
  position: fixed; z-index: 400; width: 274px; padding: 11px;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 20px); overflow-y: auto;
}
.date-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.date-pop-head strong { font-size: 12.5px; text-transform: capitalize; letter-spacing: .01em; }
.date-pop-nav {
  display: grid; place-items: center; width: 27px; height: 27px;
  border: 0; border-radius: 7px; background: var(--surface-2); color: var(--ink-2); cursor: pointer;
}
.date-pop-nav:hover { background: var(--brand-softer); color: var(--brand); }
.date-pop-nav svg { width: 14px; height: 14px; }
.date-pop-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.date-pop-dow { text-align: center; font-size: 10px; font-weight: 700; color: var(--muted); padding: 2px 0; }
.date-pop-dow.is-weekend { color: var(--danger); }
.date-pop-day {
  display: grid; place-items: center; height: 30px; min-width: 0;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; font: inherit; font-size: 11.5px; font-weight: 500;
  color: var(--ink-2); cursor: pointer;
}
.date-pop-day:hover:not(.is-blocked):not(.is-empty) { background: var(--brand-softer); }
.date-pop-day.is-empty { cursor: default; }
.date-pop-day.is-today { border-color: var(--brand); font-weight: 700; }
.date-pop-day.is-class {
  background: var(--accent-soft); color: var(--accent-dark);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
/* Dias de EV e de ET distinguem-se pela cor */
.date-pop-day.is-ev {
  background: var(--brand-soft); color: var(--brand-dark);
  box-shadow: inset 0 0 0 1.5px var(--brand);
}
.date-pop-day.is-et {
  background: var(--ok-soft); color: var(--ok);
  box-shadow: inset 0 0 0 1.5px var(--ok);
}
.date-pop-day.is-both {
  background: linear-gradient(135deg, var(--brand-soft) 0 50%, var(--ok-soft) 50% 100%);
  color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--brand);
}
.date-pop-day.is-selected { background: var(--brand); color: #fff; font-weight: 700; box-shadow: none; }
.date-pop-day.is-blocked { cursor: not-allowed; opacity: .55; }
.date-pop-day.is-weekend.is-blocked { background: var(--surface-2); color: var(--muted-2); }
.date-pop-day.is-holiday.is-blocked, .date-pop-day.is-pause.is-blocked {
  background: var(--danger-soft); color: var(--danger); opacity: .9;
}
.date-pop-day.is-municipal.is-blocked {
  background: var(--accent-soft); color: var(--accent-dark); opacity: .95;
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.date-pop-day.is-fora.is-blocked { background: transparent; color: var(--muted-2); opacity: .4; }
.date-pop-legend {
  display: flex; flex-wrap: wrap; gap: 8px 10px; margin-top: 9px;
  padding-top: 8px; border-top: 1px dashed var(--line);
  font-size: 9.5px; color: var(--muted);
}
.date-pop-legend .lg { display: inline-flex; align-items: center; gap: 4px; }
.date-pop-legend .lg::before {
  content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 3px;
}
.date-pop-legend .is-class::before { background: var(--accent-soft); border: 1.5px solid var(--accent); }
.date-pop-legend .is-ev::before { background: var(--brand-soft); border: 1.5px solid var(--brand); }
.date-pop-legend .is-et::before { background: var(--ok-soft); border: 1.5px solid var(--ok); }
.date-pop-legend .is-both::before {
  background: linear-gradient(135deg, var(--brand-soft) 0 50%, var(--ok-soft) 50% 100%);
  border: 1.5px solid var(--brand);
}
.date-pop-legend .is-weekend::before { background: var(--surface-2); border: 1px solid var(--line-strong); }
.date-pop-legend .is-sem-aula::before { background: transparent; border: 1px dashed var(--line-strong); }
.date-pop-legend .is-fora::before { background: transparent; border: 1px dotted var(--muted-2); }
.date-pop-legend .is-holiday::before { background: var(--danger-soft); border: 1px solid var(--danger); }
.date-pop-legend .is-municipal::before { background: var(--accent-soft); border: 1px solid var(--accent); }
.date-pop-foot { display: flex; justify-content: flex-end; margin-top: 6px; }

.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: 12px;
  padding: 26px; text-align: center; background: var(--surface-2);
  color: var(--muted); font-size: 12.5px;
}
.dropzone.is-over { border-color: var(--brand); background: var(--brand-softer); }

.kv-list { display: flex; flex-direction: column; }
.kv-list .kv { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 12.5px; }
.kv-list .kv:last-child { border-bottom: 0; }
.kv-list .k { color: var(--muted); }
.kv-list .v { font-weight: 600; text-align: right; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 5px; bottom: 5px; width: 1px; background: var(--line); }
.timeline-item { position: relative; padding: 0 0 18px 0; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -18px; top: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--line-strong);
}
.timeline-item.is-accent::before { border-color: var(--accent); }
.timeline-item.is-done::before { border-color: var(--brand); background: var(--brand); }

/* ---------- 19b. Componentes de interface ---------- */
.filter-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 16px 0;
}
.filter-bar .input, .filter-bar .select { height: 36px; }
.select-auto { width: auto; min-width: 150px; max-width: 260px; }

.search-wrap { position: relative; flex: 1 1 240px; min-width: 180px; max-width: 380px; }
.search-wrap .input { padding-left: 34px; width: 100%; }
.search-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted); pointer-events: none;
}
.search-icon svg { display: block; }

.scope-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 13px; margin-bottom: 16px;
  background: var(--brand-softer); border: 1px solid var(--line-strong); border-radius: 10px;
  font-size: 12.5px; color: var(--ink-2);
}
.scope-bar .scope-label { font-weight: 600; color: var(--brand-deep); }
.scope-bar-text { flex: 1; min-width: 0; }
.scope-bar-select { display: flex; align-items: center; gap: 8px; }
.list-item.is-current { background: var(--brand-softer); }
.list-item.is-current:hover { background: var(--brand-softer); }

.multi-list {
  display: flex; flex-direction: column; gap: 6px;
  border: 1px solid var(--line); border-radius: 9px; padding: 8px;
  background: var(--surface-2); max-height: 260px; overflow-y: auto;
}
.multi-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 7px;
}
.multi-row .grow { flex: 1; min-width: 0; }
.multi-row .date-field { flex: 1 1 auto; min-width: 0; }
.multi-add { align-self: flex-start; margin-top: 2px; }

.pick-list { display: flex; flex-direction: column; gap: 8px; }
.pick-list .check-grid { max-height: 230px; overflow-y: auto; padding-right: 3px; }
.pick-add { display: flex; gap: 7px; align-items: center; }
.pick-add .input { flex: 1; height: 32px; font-size: 12.5px; }
.pick-add .btn { flex: none; }

.list-compact { display: flex; flex-direction: column; }
.list-item-compact { padding: 8px 12px; gap: 10px; }
.list-item-compact .list-item-title { font-size: 12.5px; }
.list-item-compact .list-item-sub { font-size: 11px; }
.mini-turma { padding: 7px 12px; }
.mini-turma .list-item-title { font-size: 12px; }
.mini-turma .list-item-sub { font-size: 10.5px; margin-top: 0; }
.mini-turma .color-dot { width: 8px; height: 8px; }

.chip-sm { padding: 2px 7px; font-size: 11px; border-radius: 6px; }
.chip-x {
  display: inline-grid; place-items: center; width: 16px; height: 16px;
  margin-left: 1px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer;
}
.chip-x:hover { background: var(--danger-soft); color: var(--danger); }
.chip-x svg { width: 11px; height: 11px; }

.color-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  flex: none; box-shadow: 0 0 0 2px rgba(255, 255, 255, .55);
}

.resource-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 15px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--shadow-xs); transition: border-color .15s, box-shadow .15s;
}
.resource-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.resource-card .resource-title { font-size: 13px; font-weight: 650; line-height: 1.35; color: var(--ink); }
.resource-card .resource-title a { color: inherit; text-decoration: none; }
.resource-card .resource-title a:hover { color: inherit; text-decoration: underline; }
.resource-card .resource-desc { font-size: 12px; color: var(--muted); line-height: 1.5; }
.resource-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.resource-actions { display: flex; gap: 2px; opacity: .35; transition: opacity .14s; }
.resource-card:hover .resource-actions { opacity: 1; }
.resource-grid { align-items: stretch; }
.resource-card .resource-foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: auto; padding-top: 4px;
}
.resource-card .resource-url {
  font-size: 11px; color: var(--brand); word-break: break-all;
  text-decoration: none;
}
.resource-card .resource-url:hover { text-decoration: underline; }

.paseo-card .card-body { padding: 0; }
.paseo-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
}
.paseo-item:last-child { border-bottom: 0; }
.paseo-item p { flex: 1; margin: 0; font-size: 12.5px; line-height: 1.5; }
.paseo-code {
  flex: none; min-width: 32px; padding-top: 2px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--brand-deep);
}
.paseo-code.is-transversal { min-width: 18px; }
.paseo-transversal-main { flex: 1; min-width: 0; }
.paseo-transversal-main strong { font-size: 12.5px; }
.paseo-transversal-main p { margin: 2px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

.school-logo-thumb {
  width: 46px; height: 34px; flex: none; object-fit: contain;
  border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 3px;
}
.school-logo-thumb.is-empty {
  display: grid; place-items: center; color: var(--line-strong); background: var(--surface-2);
}
.school-logo-thumb.is-empty svg { width: 16px; height: 16px; }

.school-colors { display: inline-flex; align-items: center; gap: 4px; margin-right: 5px; vertical-align: -1px; }
.school-colors .color-dot { width: 10px; height: 10px; box-shadow: 0 0 0 1px var(--line-strong); }
.school-colors-preview {
  display: flex; height: 34px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line-strong); background: var(--surface-2);
}
.school-colors-preview span { flex: 1; }
.color-input { width: 100%; height: 40px; padding: 3px; cursor: pointer; }
html[data-theme="escuro"] .school-logo-thumb { background: #fff; }

/* Modo escuro: selects nativos e códigos com contraste suficiente */
html[data-theme="escuro"] .year-select select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238fa2bd' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
html[data-theme="escuro"] select option {
  background-color: var(--surface-2);
  color: var(--ink);
}
html[data-theme="escuro"] select option:checked {
  background-color: var(--brand-soft);
  color: var(--ink);
}
html[data-theme="escuro"] .paseo-code,
html[data-theme="escuro"] .scope-bar .scope-label { color: var(--brand); }

.logo-preview {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; min-height: 130px; padding: 18px;
  border: 1.5px dashed var(--line-strong); border-radius: 11px;
  background: var(--surface-2); text-align: center;
}
.logo-preview img { max-width: 100%; max-height: 130px; object-fit: contain; }
.logo-empty {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  color: var(--muted); font-size: 12px;
}
.logo-empty svg { width: 26px; height: 26px; color: var(--line-strong); }

/* ---------- 19c. Editores de planificação ---------- */
.planner-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.planner-form { padding: 0; overflow: hidden; }
.planner-form .planner-tabs { margin: 0; padding: 0 14px; }
.planner-tabs .tab { padding: 12px 13px; font-size: 12.5px; }
.planner-tabs .tab-action { margin: 6px 0 6px 8px; align-self: center; }

/* Biblioteca de unidades */
.library-photos {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.library-photo {
  position: relative; overflow: hidden; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface-2); aspect-ratio: 4 / 3;
}
.library-photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.library-photo-remove {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255, 255, 255, .92) !important;
}
.library-details { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; border-top: 1px solid var(--line); padding-top: 16px; }
.library-details > * { min-width: 0; }
.library-details .list-item { min-width: 0; }
.library-title { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-viewer { display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; padding: 10px; }
.photo-viewer img { max-width: 100%; max-height: 68vh; object-fit: contain; border-radius: 8px; display: block; }
.photo-nav { display: flex; align-items: center; justify-content: center; gap: 14px; }
.planner-panels { padding: 18px 20px 20px; }
.planner-panel .form-grid { gap: 16px 18px; }
.planner-panel > .form-grid:empty { display: none; }
.planner-actions { align-items: center; gap: 10px; padding: 2px 2px 0; }

.segmented-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 9px;
}
.segmented-btn {
  border: 0; background: none; border-radius: 6px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--muted);
  transition: background .14s, color .14s;
}
.segmented-btn:hover { color: var(--ink); }
.segmented-btn.is-active { background: var(--surface); color: var(--brand-dark); box-shadow: var(--shadow-xs); }

.quick-panels { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; position: relative; z-index: 25; }
.quick-panel {
  position: relative; flex: 0 1 auto; min-width: 0; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-xs);
}
.quick-panel summary {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; cursor: pointer; list-style: none;
  font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.quick-panel summary::-webkit-details-marker { display: none; }
.quick-panel summary > svg:first-child { width: 15px; height: 15px; color: var(--brand); flex: none; }
.quick-panel summary > svg:last-child {
  width: 14px; height: 14px; margin-left: auto; flex: none;
  color: var(--muted); transition: transform .18s var(--ease);
}
.quick-panel[open] summary > svg:last-child { transform: rotate(180deg); }
.quick-panel[open] summary { color: var(--brand-dark); }
.quick-panel-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-panel-meta { margin-left: auto; font-size: 11px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.quick-panel-body {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  width: min(460px, calc(100vw - 32px));
  max-height: min(60vh, 520px); overflow: auto;
  padding: 14px; background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg);
}
.quick-panel.is-flip .quick-panel-body { left: auto; right: 0; }

.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 22px; }
.summary-2col { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.summary-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.summary-sec { min-width: 0; }
.summary-sec.is-wide { grid-column: 1 / -1; }
.summary-sec h3 {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line);
}
.summary-text { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; white-space: pre-wrap; }
.summary-phases { display: flex; flex-direction: column; gap: 7px; }
.summary-line { display: flex; flex-direction: column; gap: 1px; font-size: 12.5px; line-height: 1.5; }
.summary-line b { color: var(--brand-dark); font-size: 11.5px; }
.summary-line span { color: var(--ink-2); }

.ai-result { margin-top: 16px; }
.ai-result:empty { display: none; }
.ai-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.ai-block {
  min-width: 0; padding: 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
.ai-block-head { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-size: 12px; }
.ai-block-head svg { width: 15px; height: 15px; color: var(--brand); flex: none; }
.ai-checks { display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow-y: auto; }
.ai-check {
  display: flex; align-items: flex-start; gap: 7px;
  padding: 4px 6px; border-radius: 6px;
  font-size: 11.5px; line-height: 1.45; color: var(--ink-2);
}
.ai-check:hover { background: var(--surface); }
.ai-check input { margin-top: 2px; accent-color: var(--brand); flex: none; }
.ai-check code { font-family: var(--mono); font-size: 10.5px; font-weight: 600; color: var(--brand-dark); }
.ai-check em { margin-left: auto; flex: none; font-style: normal; font-size: 10px; font-weight: 600; color: var(--muted); }
.ai-text { margin-top: 14px; padding: 12px; background: var(--brand-softer); border: 1px solid var(--line); border-radius: 10px; }
.ai-text .kv-list .kv { font-size: 12px; }
.ai-provider-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.ai-provider-row .select { width: auto; min-width: 190px; }
.ai-provider-note { font-size: 11.5px; color: var(--muted); }
.ai-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px; font-size: 10.5px; font-weight: 700;
  background: var(--brand-soft); color: var(--brand-dark);
}
.ai-badge.is-online { background: var(--info-soft); color: var(--info); }
.ai-ideas { margin: 0; padding-left: 18px; font-size: 12px; line-height: 1.55; color: var(--ink-2); }
.ai-ideas li + li { margin-top: 4px; }
.ai-loading { display: flex; align-items: center; gap: 8px; padding: 14px; font-size: 12.5px; color: var(--muted); }

.select-inline { height: 30px; padding: 0 8px; font-size: 12px; border-radius: 7px; max-width: 150px; }
.is-archived-row td { background: var(--surface-2); opacity: .78; }
.is-archived-row:hover td { opacity: 1; }

/* ---------- 20b. Ajustes v1.5 ---------- */
.page-sub { max-width: none; }
.section-head .section-sub { max-width: none; }

/* Cabeçalho de página: título em duas linhas, ações na mesma linha em ecrãs largos */
.page-head { align-items: flex-start; }
.page-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
@media (min-width: 810px) and (max-width: 900px), (min-width: 1074px) {
  .page-head { flex-wrap: nowrap; align-items: flex-end; gap: 16px; }
  .page-head-main { flex: 1 1 auto; min-width: 0; }
  .page-actions { flex: 0 0 auto; }
}
/* Nas larguras em que o conteúdo útil é mais estreito (janela e barra lateral),
   reserva espaço para o título e deixa as ações quebrarem dentro da própria linha. */
@media (min-width: 810px) and (max-width: 900px), (min-width: 1074px) and (max-width: 1240px) {
  .page-head-main { min-width: 220px; }
  .page-actions { flex: 0 1 auto; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
}

/* Escola e controlos do topbar */
.topbar-school {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
}
.year-select label { white-space: nowrap; }
.topbar-btn svg { width: 16px; height: 16px; }

/* Ano + designação na mesma linha */
.form-trio {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
  align-items: start;
}

/* Datas por turma nas unidades */
.per-turma-datas { border-top: 1px dashed var(--line); padding-top: 14px; }
.per-turma-datas[hidden] { display: none; }
.per-turma-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.per-turma-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 9px;
}
.per-turma-row-lembrete {
  grid-template-columns: minmax(120px, 0.8fr) minmax(0, 2.4fr);
}
.per-turma-nome {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-bottom: 9px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.per-turma-nome span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Datas por turma nas planificações: nome + mini formulário */
.per-turma-row-pa {
  grid-template-columns: minmax(120px, 0.55fr) minmax(0, 2.45fr);
  align-items: start;
}
.per-turma-row-pa .per-turma-nome { padding-top: 8px; padding-bottom: 0; }
.per-turma-form { min-width: 0; }
.per-turma-form .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.per-turma-form .field-label { font-size: 11.5px; }

/* Seletor de estado maior e rascunho realçado */
.select-state { height: 36px; min-width: 158px; max-width: none; font-size: 12.5px; }
.select.is-rascunho {
  background: var(--warn-soft);
  border-color: var(--warn);
  color: var(--warn);
  font-weight: 650;
}

/* Resumo truncado na lista de planificações */
.table td.col-summary { max-width: 380px; }
.pa-table { table-layout: fixed; min-width: 980px; }
.pa-table td.col-summary { max-width: none; }
.cell-truncate {
  display: flex;
  min-width: 0;
  flex-wrap: nowrap;
  overflow: hidden;
}
.cell-truncate-text {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-truncate .badge { flex: 0 0 auto; }

/* Paginação das listas */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
}
.pagination-info { font-size: 12px; color: var(--muted); }

/* Cor de turma não atribuída */
.color-dot.is-empty {
  background: transparent !important;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}

/* Título com ponto de cor */
.title-with-dot { display: inline-flex; align-items: center; gap: 10px; }

/* Guia rápido: respostas a toda a largura */
.faq details { border-bottom: 1px solid var(--line); }
.faq details:last-child { border-bottom: 0; }
.faq-answer { max-width: none; line-height: 1.6; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .per-turma-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .per-turma-nome { grid-column: 1 / -1; padding-bottom: 0; }
  .per-turma-row-pa { grid-template-columns: minmax(0, 1fr); }
  .per-turma-row-pa .per-turma-nome { padding-top: 0; }
}
@media (max-width: 640px) {
  .form-trio { grid-template-columns: minmax(0, 1fr); }
  .per-turma-row { grid-template-columns: minmax(0, 1fr); }
  .per-turma-form .form-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar-school { display: none; }
  .pagination { align-items: flex-start; }
  .table td.col-summary { max-width: 220px; }
}

/* ---------- 20. Print ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 16mm 14mm; }
  body { background: #fff; font-size: 11pt; }
  .sidebar, .topbar, .page-actions, .no-print, .toast-stack, .modal-overlay { display: none !important; }
  .app { display: block; }
  .app-main { background: #fff; }
  .view { padding: 0; max-width: none; animation: none; }
  .print-only { display: block; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .page-title { font-size: 22pt; }
  .table th { background: #f2f2f2 !important; }
  .grade-table { font-size: 9pt; }
  .grade-table td, .grade-table th { padding: 4px 5px; }
  a { color: inherit; text-decoration: none; }
  .print-page-break { break-before: page; }
}

/* ---------- 21. Responsive ---------- */
@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 272px;
    transform: translateX(-100%); transition: transform .24s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open::after {
    content: ""; position: fixed; inset: 0; z-index: 35;
    background: rgba(18, 31, 26, .4);
  }
  .menu-toggle { display: grid; }
  .view { padding: 22px 20px 64px; }
  .topbar { padding: 0 20px; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .page-title { font-size: 24px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat-value { font-size: 22px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: span 1; }
  .topbar-crumbs { display: none; }
  .hero { padding: 22px; }
  .hero h1 { font-size: 22px; }
  .modal-overlay { padding: 10px; }
  .modal { max-height: 92vh; }
  .page-head { align-items: flex-start; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .table th, .table td { padding: 9px 10px; }
  .summary-grid, .ai-grid { grid-template-columns: minmax(0, 1fr); }
  .planner-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; }
  .quick-panel { flex-basis: 100%; }
  .kv-list .kv { flex-direction: column; gap: 2px; }
  .kv-list .v { text-align: left; }
}
