:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0f766e;
  --brand-2: #115e59;
  --brand-ink: #ffffff;
  --accent: #1f4e79;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .05);
  font-size: 15px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
body.plain { background: linear-gradient(160deg, #ecfeff 0%, #f1f5f9 45%, #e2e8f0 100%); min-height: 100vh; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 4px; line-height: 1.25; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
.muted { color: var(--muted); font-size: .9em; }

/* Layout do app */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: 0 0 232px;
  background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand strong { display: block; color: #fff; font-size: .95rem; }
.brand small { color: #94a3b8; font-size: .72rem; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #14b8a6);
  color: #fff; font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.nav { display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; flex: 1; }
.nav a {
  color: #cbd5e1; padding: 10px 12px; border-radius: 8px; font-size: .92rem;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; color: #fff; }
.nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: .85rem; color: #94a3b8;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 14px 24px; position: sticky; top: 0; z-index: 5;
}
.content { padding: 20px 24px 40px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow);
  padding: 32px; width: 100%; max-width: 380px;
}
.brand-login { border: 0; padding: 0 0 18px; color: var(--ink); }
.brand-login strong { color: var(--ink); }

/* Cards e painéis */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card, .panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel { padding: 18px; margin-bottom: 18px; }
.stat { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat strong { font-size: 1.7rem; color: var(--accent); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head p { margin: 2px 0 0; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* Tabelas */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--line);
}
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table-compact th, .table-compact td { padding: 6px 8px; font-size: .85rem; }
.table tbody tr:hover { background: #f8fafc; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; white-space: nowrap; }
.notes-cell { max-width: 220px; color: var(--muted); font-size: .82rem; }
.inline { display: inline; margin: 0; }
.total-row td { font-weight: 700; background: #f1f5f9; }
.row-editing { background: #fffbeb !important; }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  font: inherit; font-size: .9rem; padding: 9px 14px; text-decoration: none !important;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: var(--brand-2); }
.btn-secondary { background: #e8eef5; color: var(--accent); border-color: #d5e0ec; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-danger { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.btn-sm { padding: 5px 10px; font-size: .8rem; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-sm .btn, .row-actions .btn { white-space: nowrap; }

/* Formulários */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: .85rem; font-weight: 600; color: #334155; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .form-actions, .form .form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=file], select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(15, 118, 110, .35); border-color: var(--brand);
}
textarea { resize: vertical; }
input:disabled { background: #f1f5f9; color: var(--muted); }
.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; }
.check input { width: auto; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 12px; }
.inline-form label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; font-weight: 600; color: #334155; }
.inline-form input[type=text], .inline-form input[type=number], .inline-form select { min-width: 160px; width: auto; }
.form-actions { margin-top: 4px; }

/* Alerts / badges / pills */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .9rem; }
.alert-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .02em;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-off { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.pill {
  background: #e8eef5; color: var(--accent); border-radius: 999px;
  padding: 6px 12px; font-size: .8rem; font-weight: 600;
}

/* Empresas */
.logo-thumb { width: 54px; height: 40px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 3px; }
.logo-placeholder { color: var(--muted); }
.logo-preview { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: var(--muted); }
.logo-preview img { width: 90px; height: 60px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 4px; }
.mini-link { color: var(--muted); font-size: .78rem; font-family: Consolas, monospace; }
.link-box {
  margin-top: 20px; padding: 16px; border: 1px dashed var(--brand);
  background: #f0fdfa; border-radius: var(--radius);
}
.link-box h3 { color: var(--brand-2); }
.link-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.link-row code {
  background: #fff; border: 1px solid var(--line); padding: 8px 10px; border-radius: 8px;
  font-size: .85rem; word-break: break-all; flex: 1; min-width: 240px;
}

/* Listas de configuração */
.tag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.tag-list li {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f1f5f9; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 6px 5px 12px; font-size: .85rem;
}
.tag-x {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 2px 6px; border-radius: 999px;
}
.tag-x:hover { background: #fee2e2; color: var(--danger); }

/* Agenda / dias */
.day-block { margin-top: 14px; }
.day-head {
  display: flex; gap: 10px; align-items: baseline;
  padding: 8px 10px; background: #e8eef5; border-radius: 8px 8px 0 0;
}
.day-block .table { background: #fff; border: 1px solid var(--line); border-top: 0; border-radius: 0 0 8px 8px; }
.empty { text-align: center; padding: 28px 12px; }
.filters { display: flex; justify-content: space-between; gap: 14px; width: 100%; flex-wrap: wrap; align-items: flex-end; }
.filters-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filters-form label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.filters-form select { min-width: 170px; width: auto; padding: 8px 10px; }

/* Avaliação */
.eval-table { margin-bottom: 16px; }
.eval-table thead th { background: var(--accent); color: #fff; border: 0; }
.progress { height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-bottom: 4px; max-width: 140px; }
.progress span { display: block; height: 100%; background: var(--brand); }
.grand-total {
  background: var(--accent); color: #fff; border-radius: 10px;
  padding: 14px 18px; font-size: .95rem; display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.grand-total strong { font-size: 1.1rem; }

/* Relatório */
.report-preview {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 18px; overflow-x: auto;
}
.report-header { display: flex; gap: 16px; align-items: center; justify-content: center; text-direction: ltr; margin-bottom: 14px; text-align: center; flex-direction: column; }
.report-logo { max-width: 120px; max-height: 70px; object-fit: contain; }
.report-title { display: flex; flex-direction: column; gap: 2px; font-size: .92rem; }
.report-title strong { font-size: 1.05rem; }
.report-kind { font-weight: 700; color: var(--accent); }
.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th {
  background: var(--accent); color: #fff; font-size: .78rem; padding: 7px 4px;
  border: 1px solid #9db4cc;
}
.calendar th.wk, .calendar td.wk { width: 26px; background: #e8eef5; color: var(--accent); text-align: center; font-weight: 700; font-size: .7rem; }
.calendar td {
  border: 1px solid #9db4cc; vertical-align: top; height: 74px; padding: 2px;
  font-size: .68rem; background: #fff;
}
.calendar td.out { background: #f6f6f6; color: #b0b0b0; }
.cal-day { text-align: right; font-weight: 700; color: #555; font-size: .7rem; padding: 1px 3px; }
.cal-item { background: #f3f7fb; border-radius: 4px; padding: 3px 4px; margin-top: 3px; line-height: 1.25; color: #222; }
.cal-type { font-weight: 600; color: var(--accent); }
.cal-sub { color: var(--muted); font-size: .62rem; }
.cal-more { color: var(--muted); font-style: italic; margin-top: 3px; padding-left: 3px; }
.report-footer {
  display: flex; gap: 18px; justify-content: space-between; flex-wrap: wrap;
  margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); font-size: .85rem;
}
.report-footer .sig { color: var(--muted); font-size: .8rem; }

/* Página pública */
.public-wrap { max-width: 1080px; margin: 0 auto; padding: 24px 16px 60px; }
.public-head {
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; flex-wrap: wrap;
}
.public-brand { display: flex; gap: 16px; align-items: center; }
.public-brand h1 { font-size: 1.15rem; margin: 0; }
.public-logo { max-width: 110px; max-height: 64px; object-fit: contain; }
.public-sub { margin-top: 4px; color: var(--brand); font-size: .9rem; }
.month-switch label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.month-switch select { min-width: 180px; }
.public-foot { text-align: center; color: var(--muted); font-size: .8rem; margin-top: 22px; }

@media print {
  .sidebar, .topbar, .filters, .btn, .public-foot { display: none !important; }
  .content { padding: 0; }
  .panel, .report-preview { box-shadow: none; border: 0; }
}
