@import url('https://fonts.googleapis.com/css2?family=Anton&family=Montserrat:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  /* ATA Brand Colors */
  --ata-red:          #DC2626;
  --ata-red-dark:     #B91C1C;
  --ata-red-light:    #FEE2E2;
  --ata-blue:         #2563EB;
  --ata-blue-dark:    #1D4ED8;
  --ata-blue-light:   #DBEAFE;
  --ata-green:        #059669;
  --ata-green-dark:   #047857;

  /* Semantic aliases */
  --primary:          var(--ata-red);
  --primary-hover:    var(--ata-red-dark);
  --secondary:        var(--ata-blue);
  --secondary-hover:  var(--ata-blue-dark);
  --success:          var(--ata-green);
  --success-dark:     var(--ata-green-dark);
  --warning:          #D97706;
  --warning-dark:     #B45309;
  --danger:           #DC2626;

  /* Layout & Neutral */
  --bg:           #F9FAFB;
  --card:         #FFFFFF;
  --border:       #E5E7EB;
  --border-dark:  #D1D5DB;
  --text:         #111827;
  --text-light:   #374151;
  --text-muted:   #6B7280;
  --sidebar-bg:   #111827;
  --sidebar-w:    256px;
  --header-h:     64px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
  --shadow:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.10), 0 4px 6px rgba(0,0,0,.05);

  /* Fonts */
  --font-body:     'Montserrat', 'Segoe UI', system-ui, sans-serif;
  --font-display:  'Anton', 'Impact', sans-serif;
  --font-mono:     'Inter', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

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

/* ── Layout ────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ── Sidebar ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sidebar-logo img {
  height: 52px;
  width: auto;
  object-fit: contain;
  display: block;
}

.sidebar-label {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.40);
  text-align: center;
  line-height: 1.3;
}

.sidebar-divider {
  width: 32px;
  height: 2px;
  background: var(--ata-red);
  border-radius: 2px;
  margin: 2px auto 0;
}

.sidebar-nav { flex: 1; padding: 10px 0 6px; }

.nav-section-title {
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: rgba(255,255,255,.35);
  padding: 10px 18px 4px;
  font-family: var(--font-body);
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  color: rgba(255,255,255,.72);
  font-size: 13.5px; font-weight: 500;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .13s, color .13s, border-color .13s;
  font-family: var(--font-body);
}

.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active {
  background: rgba(220,38,38,.15);
  color: #fff;
  border-left-color: var(--ata-red);
}
.nav-item.active .ni { color: var(--ata-red); }
.nav-item .ni { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: 10.5px; color: rgba(255,255,255,.28);
  text-align: center;
  font-family: var(--font-body);
}

/* ── Main content ──────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.top-header {
  background: #fff;
  border-bottom: 3px solid var(--ata-red);
  padding: 0 26px;
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow);
}

.page-title {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text);
  letter-spacing: .02em;
  line-height: 1;
}

.header-actions { display: flex; align-items: center; gap: 10px; }
.page-content { padding: 24px 26px; flex: 1; }

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #FAFAFA;
}

.card-title {
  font-family: var(--font-display);
  font-size: 15px;
  color: var(--text);
  letter-spacing: .03em;
}

.card-body { padding: 20px; }

/* ── Stats grid ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--ata-red);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-label {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 34px; color: var(--ata-red);
  line-height: 1; margin-bottom: 4px;
}

.stat-desc { font-size: 12px; color: var(--text-muted); }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px;
  border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: 1.5px solid transparent;
  transition: all .15s; white-space: nowrap;
  text-decoration: none; font-family: var(--font-body);
  letter-spacing: .01em;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--ata-red); color: #fff; border-color: var(--ata-red); }
.btn-primary:hover { background: var(--ata-red-dark); border-color: var(--ata-red-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(220,38,38,.30); }

.btn-secondary { background: var(--ata-blue); color: #fff; border-color: var(--ata-blue); }
.btn-secondary:hover { background: var(--ata-blue-dark); border-color: var(--ata-blue-dark); transform: translateY(-1px); }

.btn-outline { background: transparent; color: var(--text-light); border-color: var(--border-dark); }
.btn-outline:hover { background: var(--bg); border-color: var(--text-muted); }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #B91C1C; transform: translateY(-1px); }

.btn-success { background: var(--ata-green); color: #fff; border-color: var(--ata-green); }
.btn-success:hover { background: var(--ata-green-dark); transform: translateY(-1px); }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: var(--warning-dark); }

.btn-sm  { padding: 5px 11px; font-size: 12px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; }

/* ── Forms ─────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text); margin-bottom: 5px;
  font-family: var(--font-body);
}

.form-label.req::after { content: ' *'; color: var(--danger); }

.form-control {
  width: 100%; padding: 8px 12px;
  border: 1.5px solid var(--border-dark); border-radius: 6px;
  font-size: 13.5px; color: var(--text); background: #fff;
  transition: border-color .14s, box-shadow .14s;
  font-family: var(--font-body);
}

.form-control:focus { outline: none; border-color: var(--ata-red); box-shadow: 0 0 0 3px rgba(220,38,38,.10); }
textarea.form-control { resize: vertical; min-height: 76px; }
select.form-control { cursor: pointer; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ── Data Table ────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }

table.data-table th {
  background: #F3F4F6; color: var(--text-muted);
  font-weight: 700; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; padding: 10px 14px; text-align: left;
  border-bottom: 2px solid var(--border-dark); white-space: nowrap;
  font-family: var(--font-body);
}

table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover td { background: #FEF2F2; }

/* ── Activity Table ────────────────────────────────── */
.activity-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }

.activity-table th {
  background: var(--ata-red); color: #fff;
  padding: 10px 10px; text-align: center;
  font-size: 11px; font-weight: 700;
  border: 1px solid rgba(255,255,255,.15);
  font-family: var(--font-body); letter-spacing: .04em;
}

.activity-table th.th-left { text-align: left; }

.activity-table td { padding: 0; border: 1px solid var(--border); vertical-align: top; }

.activity-table td.month-cell {
  padding: 10px 12px; font-weight: 700; font-size: 12px;
  background: #F9FAFB; color: var(--text); white-space: nowrap; width: 110px;
  border-right: 2px solid var(--border-dark);
  font-family: var(--font-body);
}

.activity-table td.total-cell {
  text-align: center; font-weight: 700; padding: 10px 8px; width: 75px; color: var(--text-muted);
}

.activity-table td.total-cell.has-absences { color: var(--ata-red); background: #FEF2F2; }
.activity-table td.total-cell.zero { color: var(--ata-green); }

.cell-input {
  width: 100%; border: none; padding: 9px 10px;
  font-size: 12.5px; font-family: var(--font-body);
  color: var(--text); background: transparent; resize: none; min-height: 38px;
}
.cell-input:focus { outline: none; background: #FFF7F7; }

.cell-num {
  width: 100%; border: none; padding: 9px 8px;
  font-size: 13px; font-family: var(--font-body);
  color: var(--text); background: transparent; text-align: center;
}
.cell-num:focus { outline: none; background: #FFF7F7; }

/* ── Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
  font-family: var(--font-body);
}

.badge-primary { background: var(--ata-red-light);  color: #991B1B; }
.badge-trial   { background: #FEF3C7; color: #92400E; }
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-danger  { background: var(--ata-red-light); color: #991B1B; }
.badge-warning { background: #FEF3C7; color: #92400E; }
.badge-info    { background: var(--ata-blue-light); color: #1E40AF; }
.badge-gray    { background: #F3F4F6; color: #374151; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.50); z-index: 200;
  align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
  background: #fff; border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  border-top: 4px solid var(--ata-red);
}
.modal-lg { max-width: 720px; }

.modal-header {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-family: var(--font-display); font-size: 16px; letter-spacing: .03em; }
.modal-close {
  background: none; border: none; font-size: 22px;
  cursor: pointer; color: var(--text-muted); padding: 2px 6px; border-radius: 4px; line-height: 1;
}
.modal-close:hover { color: var(--ata-red); background: var(--ata-red-light); }
.modal-body   { padding: 18px 22px; }
.modal-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Alerts ────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 6px; font-size: 13px; margin-bottom: 14px; border: 1px solid; }
.alert-info    { background: #EFF6FF; border-color: #BFDBFE; color: #1E40AF; }
.alert-success { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.alert-danger  { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }

/* ── Info grid ─────────────────────────────────────── */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .07em;
}
.info-value { font-size: 14px; color: var(--text); font-weight: 600; }

/* ── Yearly Summary Bar ────────────────────────────── */
.yearly-summary {
  background: linear-gradient(135deg, var(--ata-red) 0%, #991B1B 100%);
  color: #fff;
  border-radius: 8px;
  padding: 20px 26px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: 0 4px 14px rgba(220,38,38,.30);
}

.ys-label {
  font-size: 11px; font-weight: 700; opacity: .75;
  text-transform: uppercase; letter-spacing: .09em; margin-bottom: 12px;
  font-family: var(--font-body);
}
.ys-stats { display: flex; gap: 30px; }
.ys-stat { text-align: center; }
.ys-val  { font-family: var(--font-display); font-size: 30px; line-height: 1; }
.ys-desc { font-size: 10px; opacity: .72; margin-top: 3px; text-transform: uppercase; letter-spacing: .06em; }
.ys-year { font-family: var(--font-display); font-size: 60px; opacity: .12; line-height: 1; }

/* ── Decision section (trial) ──────────────────────── */
.decision-section {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-top: 3px solid #D97706;
  border-radius: 0 0 6px 6px;
  padding: 14px 16px;
}
.decision-title {
  font-family: var(--font-body);
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: #92400E; margin-bottom: 12px;
}
.decision-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.decision-party-label {
  font-size: 12px; font-weight: 700; color: var(--ata-red);
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
  font-family: var(--font-body);
}
.check-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.check-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer; font-family: var(--font-body);
}
.check-item input[type=checkbox],
.check-item input[type=radio] {
  width: 15px; height: 15px; cursor: pointer; accent-color: var(--ata-red); flex-shrink: 0;
}
.sig-mini { margin-top: 8px; }
.sig-mini-label {
  font-size: 10.5px; color: var(--text-muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px;
  font-family: var(--font-body);
}
.sig-mini-line  { border-bottom: 1px solid #9CA3AF; height: 28px; margin-bottom: 4px; }
.sig-mini-name  { font-size: 11px; color: var(--text-muted); font-family: var(--font-body); }

/* ── Audit Section ─────────────────────────────────── */
.audit-row td { padding: 0 !important; }
.audit-section {
  background: #FFF7ED;
  border: 1px solid #FED7AA;
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 14px 16px;
  display: none;
}
.audit-section.open { display: block; }
.audit-title {
  font-family: var(--font-body);
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--warning); margin-bottom: 12px;
}
.audit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.etica-section {
  margin-top: 12px; background: #ECFDF5;
  border: 1px solid #A7F3D0; border-radius: 6px; padding: 12px 14px;
}
.etica-title {
  font-family: var(--font-body);
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ata-green); margin-bottom: 10px;
}

/* ── Signature Section ─────────────────────────────── */
.signature-section { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 22px; }
.signature-box { border: 1px solid var(--border); border-radius: 6px; padding: 16px; }
.sig-role {
  font-family: var(--font-body);
  font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--text-muted); margin-bottom: 12px;
}
.sig-line { border-bottom: 1px solid var(--text); height: 36px; margin-bottom: 7px; }
.sig-name { font-size: 12px; color: var(--text-muted); font-family: var(--font-body); }
.sig-date { font-size: 11px; color: var(--text-muted); margin-top: 6px; }

/* ── Toast ─────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 7px; }
.toast {
  background: #111827; color: #fff;
  padding: 11px 16px; border-radius: 6px;
  font-size: 13px; box-shadow: var(--shadow-md);
  max-width: 320px; font-family: var(--font-body);
  animation: toastIn .22s ease;
}
.toast.success { background: var(--ata-green); }
.toast.error   { background: var(--ata-red); }
.toast.warning { background: var(--warning); }
@keyframes toastIn {
  from { transform: translateX(110%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── Empty State ───────────────────────────────────── */
.empty-state { text-align: center; padding: 52px 20px; color: var(--text-muted); }
.empty-icon  { font-size: 44px; margin-bottom: 14px; opacity: .3; }
.empty-title { font-family: var(--font-display); font-size: 18px; color: var(--text); margin-bottom: 6px; letter-spacing: .03em; }
.empty-state p { font-size: 13.5px; margin-bottom: 14px; }

/* ── Filters bar ───────────────────────────────────── */
.filters-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-wrap { flex: 1; min-width: 200px; max-width: 300px; }

/* ── Print ─────────────────────────────────────────── */
@media print {
  .sidebar, .top-header, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  body { background: #fff; font-size: 10.5pt; }
  .card { box-shadow: none !important; border: 1px solid #E5E7EB !important; margin-bottom: 12px !important; }

  .yearly-summary {
    background: var(--ata-red) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .activity-table th {
    background: var(--ata-red) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-doc-header {
    display: block !important;
    text-align: center;
    border-bottom: 3px solid var(--ata-red);
    padding-bottom: 14px;
    margin-bottom: 20px;
  }
  .print-doc-header img { height: 56px; margin: 0 auto 8px; display: block; }
  .print-doc-header h1 { font-family: var(--font-display); font-size: 18pt; color: var(--ata-red); }
  .print-doc-header h2 { font-size: 12pt; font-weight: 600; margin-top: 4px; color: var(--text); }
  .print-doc-header p  { font-size: 10pt; color: #555; margin-top: 3px; }

  .cell-input, .cell-num { pointer-events: none; }
  .audit-section, .decision-section { border: 1px solid #ccc !important; }
  @page { margin: 18mm; size: A4; }
  .page-break { page-break-before: always; }
}

/* ── Misc Utilities ────────────────────────────────── */
hr.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-center  { display: flex; align-items: center; gap: 8px; }
.flex-end     { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }

.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 12px; }
.text-danger  { color: var(--ata-red); }
.text-success { color: var(--ata-green); }
.text-blue    { color: var(--ata-blue); }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.mb-0         { margin-bottom: 0 !important; }
.mt-12        { margin-top: 12px; }
.mt-16        { margin-top: 16px; }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: var(--ata-red);
  border-radius: 50%; animation: spin .5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Red accents on hover rows */
table.data-table tbody tr:hover td { background: #FEF2F2; }
tr.has-absence td { background: #FFFBEB !important; }
tr.many-absences td { background: #FEF2F2 !important; }

/* Print-doc-header hidden on screen */
.print-doc-header { display: none; }
