:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --border: #dbe1e8;
  --text: #1f2933;
  --muted: #6b7684;
  --primary: #2f6fed;
  --primary-text: #ffffff;
  --danger: #d9534f;
  --danger-text: #ffffff;
  --present: #2e7d32;
  --absent: #c62828;
  --weekoff: #6b7684;
  --holiday: #b8860b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

header.app-header {
  background: var(--primary);
  color: var(--primary-text);
  padding: 14px 16px;
  font-size: 1.15rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header.app-header small {
  font-weight: 400;
  font-size: 0.75rem;
  opacity: 0.85;
}

nav.tabs {
  display: flex;
  overflow-x: auto;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 48px;
  z-index: 9;
}

nav.tabs button {
  flex: 0 0 auto;
  padding: 12px 16px;
  border: none;
  background: none;
  font-size: 0.92rem;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

nav.tabs button.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

main {
  padding: 12px;
  max-width: 1100px;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.filter-bar {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 140px;
  flex: 1 1 140px;
}

.field.grow-2 { flex: 2 1 220px; }

.field label {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

input, select, button, textarea {
  font-family: inherit;
  font-size: 0.95rem;
}

input, select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

button {
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

button.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
button.danger { background: var(--danger); color: var(--danger-text); border-color: var(--danger); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.status-line {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 4px 0;
}

.summary-line {
  font-weight: 700;
  color: var(--primary);
  font-size: 0.9rem;
  margin: 4px 0 10px;
}

.summary-line .absent { color: var(--absent); }
.summary-line .present { color: var(--present); }

.list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.data-table th, table.data-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table th {
  background: #f0f3f7;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.quick-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.quick-card h3 { margin: 0 0 8px; }

.quick-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.quick-actions button.big {
  flex: 1 1 0;
  padding: 16px;
  font-size: 1.05rem;
  font-weight: 600;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.82rem;
}

.btn-sm.danger { background: var(--danger); color: var(--danger-text); border-color: var(--danger); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge.present { background: #e6f4ea; color: var(--present); }
.badge.absent { background: #fdecea; color: var(--absent); }
.badge.weekoff { background: #eceff1; color: var(--weekoff); }
.badge.holiday { background: #fff6e0; color: var(--holiday); }

.empty-hint {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100;
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--panel);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
}

.modal h3 { margin: 0 0 14px; }

.modal .field { margin-bottom: 12px; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.checkbox-row input { width: auto; }

.toast {
  position: fixed;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  background: #263238; color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.88rem;
  z-index: 200;
  max-width: 90vw;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.toast.error { background: var(--danger); }
.toast.hidden { display: none; }

/* Desktop: modal centers instead of sliding from bottom */
@media (min-width: 720px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: var(--radius); }
  .filter-bar .field { flex: 1 1 160px; }
}

/* Small phones: stack table as cards */
@media (max-width: 560px) {
  table.data-table thead { display: none; }
  table.data-table, table.data-table tbody, table.data-table tr, table.data-table td {
    display: block;
    width: 100%;
  }
  table.data-table tr {
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
  }
  table.data-table td {
    border: none;
    padding: 3px 0;
    white-space: normal;
  }
  table.data-table td::before {
    content: attr(data-label);
    display: inline-block;
    min-width: 90px;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    margin-right: 6px;
  }
  .actions-row button { flex: 1 1 auto; }
}
