@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --ink: #14171a;
  --ink-soft: #5b6168;
  --ink-faint: #8a9096;
  --line: #e6e8e5;
  --brand: #1f5f4f;
  --brand-dark: #163f34;
  --brand-darker: #0f2b23;
  --brand-soft: #e6efec;
  --accent: #c98a3a;
  --danger: #b8433a;
  --danger-soft: #fbe9e7;
  --warn: #b8863a;
  --warn-soft: #fbf0dc;
  --ok: #2f7d5a;
  --ok-soft: #e4f3ea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20,23,26,.04), 0 8px 24px rgba(20,23,26,.05);
  --shadow-lg: 0 8px 30px rgba(15,43,35,.14);
  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w: 252px;
  --topbar-mobile-h: 58px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

a { color: var(--brand); }
img { max-width: 100%; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ================= Auth pages ================= */
.auth-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at top left, var(--brand-soft), var(--bg) 55%);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.auth-card .brand {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-card .brand img { height: 34px; width: auto; border-radius: 6px; }

.auth-card .sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 24px;
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink);
}

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=file], input[type=time], input[type=number], select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
  font-family: var(--font-body);
  background: #fff;
  margin-bottom: 16px;
  transition: border-color .15s, box-shadow .15s;
  color: var(--ink);
}

@media (min-width: 640px) {
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=file], input[type=time], input[type=number], select, textarea {
    font-size: 14px;
  }
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

input[type=file] { padding: 8px; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  min-height: 42px;
  border-radius: 8px;
  border: none;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .06s ease, opacity .15s, background .15s;
  white-space: nowrap;
}

button:active, .btn:active { transform: scale(0.98); }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--brand-soft); color: var(--brand-dark); }
.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; min-height: 34px; font-size: 12.5px; }
.btn-block { width: 100%; }
button:disabled { opacity: .5; cursor: not-allowed; }

.error-box {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.success-box {
  background: var(--ok-soft);
  color: var(--ok);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}

.demo-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
}

/* ================= App shell (sidebar dashboard layout) ================= */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--brand-darker);
  color: #eef3f1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transform: translateX(0);
  transition: transform .22s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 18px 14px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  min-width: 0;
}

.brand-mark { font-size: 20px; }
.brand-logo { height: 32px; width: auto; max-width: 140px; border-radius: 6px; object-fit: contain; background: #fff; padding: 2px; }
.brand-logo-sm { height: 24px; width: auto; border-radius: 5px; object-fit: contain; }

.brand-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-close { display: none; background: none; border: none; color: #cfe0d9; font-size: 18px; padding: 6px; min-height: auto; }

.sidebar-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #7fa295;
  padding: 12px 20px 6px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 9px;
  color: #cfe0d9;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 6px; margin-bottom: 6px; }
.sidebar-user-info { min-width: 0; }
.sidebar-user-info .name { font-size: 13.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-info .role { font-size: 11.5px; color: #93b1a6; }

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #f3c9c3;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  transition: background .15s;
}
.sidebar-logout:hover { background: rgba(184,67,58,.22); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,20,18,.5);
  z-index: 35;
}

.main-wrap {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: var(--topbar-mobile-h);
  padding: 0 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-mobile-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14.5px;
  color: var(--brand-dark);
  overflow: hidden;
}
.topbar-mobile-brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.hamburger {
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  min-height: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}
.avatar-sm { width: 32px; height: 32px; font-size: 12px; }

.content { flex: 1; padding: 28px 0 60px; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: inline-flex; }
  .sidebar-backdrop.open { display: block; }
  .main-wrap { margin-left: 0; }
  .topbar-mobile { display: flex; }
  .content { padding: 20px 0 48px; }
  .container { padding: 0 16px; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-head h1 { font-size: 25px; margin: 0 0 4px; }
.page-head p { margin: 0; color: var(--ink-soft); font-size: 14px; }

@media (max-width: 600px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .btn { width: 100%; }
}

.rate-pill {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--brand-soft);
  white-space: nowrap;
}
.rate-pill-value {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--brand-dark);
}
.rate-pill-label { font-size: 12.5px; color: var(--ink-soft); }
@media (max-width: 600px) {
  .rate-pill { justify-content: center; }
}

/* ================= Cards / grid ================= */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card-title h2 { font-size: 16px; margin: 0; }
.card-title .text-muted { font-size: 12.5px; }

.stat-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.stat-card .label { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 500; }
.stat-card .value { font-family: var(--font-display); font-size: 28px; font-weight: 600; line-height: 1; }
.stat-card .value.ok { color: var(--ok); }
.stat-card .value.warn { color: var(--warn); }
.stat-card .value.danger { color: var(--danger); }
.stat-card .icon-badge {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-dark); flex-shrink: 0;
}
.stat-card .icon-badge svg { width: 19px; height: 19px; }
.stat-card .icon-badge.ok { background: var(--ok-soft); color: var(--ok); }
.stat-card .icon-badge.warn { background: var(--warn-soft); color: var(--warn); }
.stat-card .icon-badge.danger { background: var(--danger-soft); color: var(--danger); }

/* ================= Chart cards ================= */
.chart-card { min-height: 300px; display: flex; flex-direction: column; }
.chart-wrap { position: relative; flex: 1; min-height: 220px; }
.chart-wrap canvas { max-width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 12.5px; color: var(--ink-soft); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--ink-faint); font-size: 13px; }

/* ================= Clock card ================= */
.clock-card {
  text-align: center;
  padding: 36px 24px;
  background: linear-gradient(165deg, var(--brand-soft), var(--surface) 60%);
}

.clock-time {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -1px;
  margin-bottom: 4px;
}

.clock-date { color: var(--ink-soft); font-size: 14px; margin-bottom: 24px; }

.wifi-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 22px;
}

.wifi-status.ok { background: var(--ok-soft); color: var(--ok); }
.wifi-status.no { background: var(--danger-soft); color: var(--danger); }
.wifi-status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.dot-blink { animation: blink 1.6s infinite; }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.clock-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.clock-actions button { flex: 1; min-width: 130px; max-width: 200px; }

/* ================= Badges ================= */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-present { background: var(--ok-soft); color: var(--ok); }
.badge-late { background: var(--warn-soft); color: var(--warn); }
.badge-absent { background: var(--danger-soft); color: var(--danger); }
.badge-half_day { background: var(--brand-soft); color: var(--brand-dark); }

/* ================= Tables ================= */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); }
th { color: var(--ink-soft); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table { min-width: 560px; }

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
  margin-bottom: 20px;
}
.filters .field { min-width: 160px; flex: 1; }
.filters label { margin-bottom: 4px; }
.filters input, .filters select { margin-bottom: 0; }
@media (max-width: 640px) {
  .filters { flex-direction: column; align-items: stretch; }
  .filters .field { min-width: 0; }
  .filters button { width: 100%; }
}

.pill-tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.pill-tabs a {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
}
.pill-tabs a.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.text-muted { color: var(--ink-soft); }
.mt-0 { margin-top: 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ================= Logo uploader (settings) ================= */
.logo-uploader { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.logo-preview {
  width: 68px; height: 68px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.logo-preview img { width: 100%; height: 100%; object-fit: contain; }
.logo-preview .placeholder { font-size: 24px; color: var(--ink-faint); }

section[id] { scroll-margin-top: 80px; }
