/* Auricullare — Controle de Ponto
 * Clean, modern, responsive UI. Pure CSS, no frameworks.
 */
:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --primary: #0f766e;       /* teal-700 */
  --primary-hover: #115e59;
  --primary-soft: #ccfbf1;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --gray: #6b7280;
  --gray-soft: #f3f4f6;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--primary); font-size: 16px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  display: grid; place-items: center; color: white; font-size: 14px;
}
.user-chip {
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; color: var(--text-muted);
}
.user-chip strong { color: var(--text); }

.container {
  max-width: 1200px; margin: 0 auto; padding: 24px;
  width: 100%;
}

/* ---------- Auth (login) ---------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(135deg, #ecfdf5 0%, #f0f9ff 100%);
  padding: 24px;
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  padding: 32px;
  width: 100%; max-width: 380px;
}
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.auth-card .sub { color: var(--text-muted); margin-bottom: 24px; font-size: 13px; }
.hint {
  margin-top: 16px; padding: 12px; background: var(--surface-2);
  border-radius: var(--radius-sm); font-size: 12px; color: var(--text-muted);
  border: 1px dashed var(--border);
}
.hint code { background: white; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
  background: white;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,118,110,0.12);
}
.field textarea { resize: vertical; min-height: 80px; }
.row { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  background: var(--gray-soft); color: var(--text);
  transition: background .15s, transform .05s;
  font-family: inherit;
}
.btn:hover { background: #e5e7eb; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: white; border-color: var(--border); }
.btn-outline:hover { background: var(--gray-soft); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.card-h h2 { margin: 0; font-size: 16px; }
.card-h .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 20px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.kpi .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.kpi .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Color coding */
.text-pos { color: var(--success); }
.text-neg { color: var(--danger); }
.text-gray { color: var(--gray); }
.bg-pos { background: var(--success-soft); color: var(--success); }
.bg-neg { background: var(--danger-soft); color: var(--danger); }
.bg-gray { background: var(--gray-soft); color: var(--gray); }
.bg-warn { background: var(--warning-soft); color: var(--warning); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--surface-2); font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px; border: none; background: transparent; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  font-family: inherit; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- Punch buttons ---------- */
.punch-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 8px;
}
.punch-btn {
  padding: 18px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-family: inherit;
  transition: all .15s;
}
.punch-btn:hover:not([disabled]) {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
}
.punch-btn[disabled] { opacity: .45; cursor: not-allowed; }
.punch-btn .icon { font-size: 24px; }
.punch-btn .label { font-weight: 600; font-size: 13px; }
.punch-btn .time { font-size: 11px; color: var(--text-muted); }
.punch-btn.done { border-color: var(--success); background: var(--success-soft); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.5);
  display: grid; place-items: center; z-index: 100; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; max-width: 480px; width: 100%;
  box-shadow: var(--shadow-md);
  max-height: 90vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 4px; font-size: 18px; }
.modal .modal-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--text); color: white; padding: 12px 20px;
  border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-md); z-index: 200;
  opacity: 0; transition: all .25s; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warn { background: var(--warning); }

/* ---------- Utilities ---------- */
.spaced { margin-top: 20px; }
.muted { color: var(--text-muted); font-size: 13px; }
.small { font-size: 12px; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 13px; }
.alert {
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px;
  margin-bottom: 16px; border-left: 3px solid;
}
.alert-warn { background: var(--warning-soft); border-color: var(--warning); color: #92400e; }
.alert-info { background: #dbeafe; border-color: #3b82f6; color: #1e40af; }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .container { padding: 16px; }
  .kpi .value { font-size: 20px; }
}

/* Weekly closing widgets */
.week-card { border-left: 4px solid var(--primary); }
.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 4px 0 4px;
}
.week-grid > div { min-width: 0; }
