:root {
  --bg: #f4f4f5;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #525252;
  --line: #e5e5e5;
  --blue: #111111;
  --blue-soft: #f5f5f5;
  --red: #111111;
  --green: #111111;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  color: var(--ink);
  background: #f4f4f5;
  font-size: 14px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; letter-spacing: -0.03em; }
.hidden { display: none !important; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}
.login-hero {
  padding: 8vw;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #111;
}
.login-mark {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
}
.login-hero h1 {
  font-size: clamp(32px, 4vw, 52px);
  line-height: 1.08;
  margin: 28px 0 12px;
  max-width: 540px;
}
.login-hero p { max-width: 440px; color: #d4d4d4; font-size: 16px; }
.login-side { display: grid; place-items: center; padding: 32px; }
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.login-card h2 { font-size: 24px; margin-bottom: 8px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }
.login-card label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 8px; }
.login-card input, .field input, .field select, .field textarea, .search-wrap input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  outline: none;
}
.login-card input:focus, .field input:focus, .field select:focus, .field textarea:focus, .search-wrap input:focus {
  border-color: #111;
  box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.12);
}
.login-card button {
  background: #111;
  color: #fff;
  border: 0;
}
.login-card button {
  width: 100%;
  height: 44px;
  border-radius: 12px;
  margin-top: 14px;
  font-weight: 700;
}
.login-error {
  display: none;
  background: #fef2f2;
  color: #be123c;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.login-error.show { display: block; }

.app { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.topbar.compact { height: 56px; }

.hamburger, .icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #334155;
  display: grid;
  place-items: center;
  flex: 0 0 40px;
  padding: 0;
}
.hamburger:hover, .icon-btn:hover, .btn:hover:not(.btn-primary):not(.btn-pdf), .drawer-item:hover {
  background: #f5f5f5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #111;
  font-size: 13px;
  font-weight: 800;
}
.brand-text { font-size: 15px; }

.search-wrap {
  flex: 1;
  max-width: 520px;
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 13px;
  color: #94a3b8;
}
.search-wrap input { padding-left: 40px; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sync {
  font-size: 12px;
  color: #111;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sync .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #111;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #111;
  color: #fff;
  font-weight: 800;
}

.drawer-shade,
.drawer-shade[hidden] {
  display: none !important;
  pointer-events: none !important;
}
.drawer-shade.is-open {
  display: block !important;
  pointer-events: auto !important;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  z-index: 80;
  border: 0;
}
.drawer {
  display: none !important;
  pointer-events: none !important;
}
.drawer.is-open {
  display: flex !important;
  pointer-events: auto !important;
  position: fixed;
  top: 0;
  left: 0;
  width: min(300px, 86vw);
  height: 100vh;
  z-index: 90;
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 16px 0 40px rgba(15, 23, 42, 0.12);
  padding: 16px;
  flex-direction: column;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.drawer-label {
  margin: 14px 8px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #94a3b8;
}
.drawer-item {
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  color: #334155;
  text-align: left;
  font-weight: 600;
}
.drawer-item.active {
  background: #111;
  color: #fff;
  font-weight: 700;
}
.drawer-foot {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.main {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 64px;
}
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 { font-size: 30px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid #d4d4d4;
  background: #fff;
  color: #111;
  font-weight: 700;
  transition: transform .2s ease, background .2s ease, color .2s ease;
}
.btn:hover { transform: translateY(-1px); background: #f5f5f5; }
.btn.btn-primary,
button.btn-primary {
  background: #111 !important;
  color: #fff !important;
  border: 1px solid #111 !important;
  min-width: 180px;
  font-size: 15px;
}
.btn.btn-primary:hover,
button.btn-primary:hover {
  background: #000 !important;
  color: #fff !important;
}
.btn.btn-pdf,
button.btn-pdf {
  background: #111 !important;
  color: #fff !important;
  border: 1px solid #111 !important;
  min-width: 150px;
}
.btn.btn-pdf:hover,
button.btn-pdf:hover {
  background: #000 !important;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
.stat strong { font-size: 28px; font-weight: 800; letter-spacing: -0.04em; color: #111; }
.stat-alert strong { color: #111; }
.stat-next { font-size: 18px !important; color: #111 !important; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}
.section-head h2 { font-size: 18px; }
.section-head span { color: var(--muted); font-size: 13px; }
.today { margin-bottom: 24px; }
.today-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.today-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.today-card h3 {
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.count {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: #111;
  border-radius: 999px;
  padding: 3px 8px;
}
.today-item {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  text-align: left;
}
.today-empty { color: var(--muted); font-size: 13px; }

.board {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.9fr 0.9fr;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}
.field textarea { height: 92px; padding: 10px 12px; resize: vertical; }
.field.wide { grid-column: 1 / -1; }
.tabs {
  display: flex;
  gap: 6px;
  padding: 10px 16px 0;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 2px solid transparent;
  font-weight: 650;
}
.tab.active { color: var(--ink); border-bottom-color: var(--blue); }

.table-wrap { overflow: auto; max-height: 68vh; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #64748b;
  padding: 12px 16px;
  background: #f8fafc;
  position: sticky;
  top: 0;
}
td { padding: 13px 16px; border-top: 1px solid var(--line); }
.processo { color: var(--blue); font-weight: 700; }
.chip {
  display: inline-flex;
  background: #111;
  color: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}
.row-actions { display: flex; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

.board-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.pager { display: flex; gap: 6px; flex-wrap: wrap; }
.page-btn {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-weight: 650;
}
.page-btn.active {
  background: #111;
  color: #fff;
  border-color: #111;
}
.page-btn:disabled { opacity: .4; }

.matrix { display: none; padding: 16px; }
.matrix.active { display: block; }
.matrix-grid {
  display: grid;
  grid-template-columns: 100px repeat(4, 1fr);
  gap: 8px;
}
.matrix-cell {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 52px;
  padding: 8px;
  background: #fbfdff;
}
.matrix-head { background: #f8fafc; font-weight: 700; display: grid; place-items: center; }
.slot {
  background: #111;
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}
.free { color: #94a3b8; font-size: 12px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  place-items: center;
  z-index: 100;
  padding: 20px;
}
.modal.open { display: grid; }
.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
}
.modal-head, .modal-body { padding: 18px 20px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #0f172a;
  color: #fff;
  padding: 12px 14px;
  border-radius: 12px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .25s ease;
  z-index: 110;
}
.toast.show { opacity: 1; transform: none; }

.export-dialog {
  border: 0;
  border-radius: 20px;
  padding: 24px;
  width: min(440px, 92vw);
}
.export-dialog::backdrop { background: rgba(15,23,42,.4); }
.export-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

@media (max-width: 1100px) {
  .stats, .today-grid, .filters { grid-template-columns: 1fr 1fr; }
  .sync { display: none; }
}
@media (max-width: 760px) {
  .login-wrap { display: block; }
  .login-hero { min-height: 32vh; padding: 36px 24px; }
  .stats, .today-grid, .filters, .form-grid { grid-template-columns: 1fr; }
  .main { width: calc(100% - 24px); padding-top: 20px; }
  .page-head { display: block; }
  .page-actions { margin-top: 12px; }
  .topbar { padding: 0 12px; }
}
