@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500&display=swap');

/* ============ THEME TOKENS ============ */
:root {
  --bg: #f2f5f3;
  --bg-gradient: linear-gradient(180deg, #fbfcfb 0%, #f0f4f1 100%);
  --surface: rgba(255,255,255,0.86);
  --surface-solid: #ffffff;
  --surface-2: rgba(255,255,255,0.6);
  --surface-border: rgba(20,32,26,0.07);
  --text-primary: #14201a;
  --text-secondary: #566159;
  --text-muted: #8b968f;
  --accent: #17a967;
  --accent-strong: #0d8a52;
  --accent-soft: #e3f7ec;
  --accent-soft-border: #c3ecd6;
  --accent-text-on-soft: #0d9256;
  --accent-gradient: linear-gradient(135deg, #17a967, #0d8a52);
  --on-accent: #ffffff;
  --danger: #d0453b;
  --danger-soft: #fdecea;
  --danger-border: #f4c9c4;
  --card-shadow: 0 10px 30px rgba(20,60,45,0.08), 0 2px 8px rgba(20,60,45,0.04);
  --pop-shadow: 0 20px 50px rgba(20,60,45,0.14);
  --radius-lg: 24px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --blur: blur(20px);
  --working-bg: #fff4d9;
  --working-text: #8a5a06;
  --working-border: #f4dfa8;
}

[data-theme="dark"] {
  --bg: #060907;
  --bg-gradient: linear-gradient(180deg, #0d1512 0%, #070a08 55%, #050605 100%);
  --surface: rgba(255,255,255,0.055);
  --surface-solid: #101613;
  --surface-2: rgba(255,255,255,0.03);
  --surface-border: rgba(255,255,255,0.09);
  --text-primary: #f2f5f3;
  --text-secondary: #a9b3ae;
  --text-muted: #6f7a74;
  --accent: #3ddc97;
  --accent-strong: #6ee7b0;
  --accent-soft: rgba(61,220,151,0.14);
  --accent-soft-border: rgba(110,231,176,0.25);
  --accent-text-on-soft: #6ee7b0;
  --accent-gradient: linear-gradient(135deg, #1a3d2e, #0c211a);
  --on-accent: #6ee7b0;
  --danger: #f0776d;
  --danger-soft: rgba(240,119,109,0.12);
  --danger-border: rgba(240,119,109,0.28);
  --card-shadow: 0 8px 30px rgba(0,0,0,0.35);
  --pop-shadow: 0 24px 60px rgba(0,0,0,0.5);
  --working-bg: rgba(255,196,61,0.14);
  --working-text: #ffcf5c;
  --working-border: rgba(255,196,61,0.25);
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ TOPBAR ============ */
.topbar {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--surface-border);
  color: var(--text-primary);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.3px; display: flex; align-items: center; gap: 8px; }
.topbar .brand .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  color: var(--on-accent); font-weight: 800; font-size: 0.8rem;
}
.topbar .brand span { font-weight: 500; opacity: 0.6; font-size: 0.82rem; margin-left: 2px; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.topbar nav a {
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: 100px;
  font-size: 0.9rem;
  font-weight: 600;
}
.topbar nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text-primary); }
.topbar nav a.active { background: var(--accent-soft); color: var(--accent-text-on-soft); }
.topbar .right { display: flex; align-items: center; gap: 8px; }
.topbar .user-info { color: var(--text-secondary); font-size: 0.88rem; font-weight: 500; }
.topbar .user-info a { color: var(--text-secondary); font-weight: 600; }

.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: var(--surface-2);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.theme-toggle:hover { background: var(--surface); }
.theme-toggle:active { transform: scale(0.92); }

/* ============ LAYOUT ============ */
.container { max-width: 1000px; margin: 0 auto; padding: 28px 20px 80px; }
.container.narrow { max-width: 460px; padding-bottom: 110px; }

.card {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  padding: 24px;
  margin-bottom: 20px;
  transition: background 0.4s ease, border-color 0.4s ease;
}

h1 { font-size: 1.6rem; margin: 0 0 6px; font-weight: 800; letter-spacing: -0.5px; }
h2 { font-size: 1.05rem; margin: 0 0 14px; font-weight: 700; letter-spacing: -0.2px; }
p.subtitle { color: var(--text-secondary); margin-top: 0; font-size: 0.95rem; }

/* ============ LOGIN ============ */
.center-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg-gradient);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--surface-border);
  border-radius: 32px;
  box-shadow: var(--pop-shadow);
  padding: 40px 32px;
  text-align: center;
  position: relative;
}
.login-card .theme-toggle { position: absolute; top: 20px; right: 20px; }
.login-card .logo {
  width: 60px; height: 60px;
  background: var(--accent-gradient);
  border-radius: 18px;
  color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.5rem;
  margin: 0 auto 18px;
  box-shadow: 0 10px 24px rgba(23,169,103,0.25);
}
.login-card h1 { font-size: 1.35rem; }

label { display: block; font-weight: 600; font-size: 0.85rem; margin: 16px 0 6px; text-align: left; color: var(--text-secondary); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=date], select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface-2);
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b968f' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-block;
  background: var(--accent-gradient);
  color: var(--on-accent);
  border: none;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 16px rgba(23,169,103,0.22);
}
[data-theme="dark"] .btn { box-shadow: none; border: 1px solid var(--accent-soft-border); }
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn.block { display: block; width: 100%; margin-top: 20px; }
.btn.secondary { background: var(--surface-2); color: var(--text-primary); border: 1px solid var(--surface-border); box-shadow: none; }
.btn.secondary:hover { background: var(--surface); }
.btn.danger { background: var(--danger); color: #fff; box-shadow: none; }
.btn.danger:hover { background: var(--danger); opacity: 0.9; }
.btn.small { padding: 7px 13px; font-size: 0.83rem; border-radius: 10px; }
.btn.big { padding: 18px; font-size: 1.1rem; border-radius: 18px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ============ TABLE ============ */
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--surface-border); }
th { color: var(--text-muted); font-weight: 700; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.5px; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }

/* ============ BADGES / PILLS ============ */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.74rem;
  font-weight: 700;
}
.badge.active { background: var(--accent-soft); color: var(--accent-text-on-soft); border: 1px solid var(--accent-soft-border); }
.badge.inactive { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--surface-border); }
.badge.working { background: var(--working-bg); color: var(--working-text); border: 1px solid var(--working-border); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 100px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.3px; }
.pill.working { background: var(--working-bg); color: var(--working-text); border: 1px solid var(--working-border); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse-dot 1.8s infinite; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ============ FLASH ============ */
.flash { padding: 13px 16px; border-radius: var(--radius-md); margin-bottom: 16px; font-size: 0.9rem; font-weight: 500; border: 1px solid; }
.flash.success { background: var(--accent-soft); color: var(--accent-text-on-soft); border-color: var(--accent-soft-border); }
.flash.error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }

.empty-state { text-align: center; padding: 44px 20px; color: var(--text-muted); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-box {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 18px;
}
.stat-box .value { font-size: 1.7rem; font-weight: 800; color: var(--text-primary); font-family: 'JetBrains Mono', monospace; letter-spacing: -1px; }
.stat-box .label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 600; margin-top: 2px; }

/* ============ NOTES ============ */
.note-item {
  background: var(--surface-2);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 12px;
}
.note-item .note-head { display: flex; align-items: center; gap: 8px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: var(--accent-text-on-soft); margin-bottom: 8px; }
.note-item .meta { font-size: 0.76rem; color: var(--text-muted); margin-top: 10px; }

/* ============ QR PRINT PAGE ============ */
.qr-box { text-align: center; padding: 24px; }
.qr-box img { border-radius: var(--radius-lg); padding: 16px; background: #fff; box-shadow: var(--card-shadow); }

/* ============ FILTERS ============ */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters .field { display: flex; flex-direction: column; }
.filters label { margin: 0 0 4px; }

/* ============ SCAN STATUS ============ */
.scan-status { text-align: center; padding: 20px; }
.scan-status .status-icon {
  width: 72px; height: 72px; margin: 0 auto 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.scan-status.success .status-icon { background: var(--accent-soft); color: var(--accent-text-on-soft); }
.scan-status.error .status-icon { background: var(--danger-soft); color: var(--danger); }

/* ============ ELAPSED-TIME RING (employee status card) ============ */
.status-card { text-align: center; }
.ring-wrap { width: 148px; height: 148px; margin: 0 auto 18px; position: relative; display: flex; align-items: center; justify-content: center; }
.ring-wrap svg { position: absolute; top: 0; left: 0; transform: rotate(-90deg); }
.ring-track { stroke: var(--surface-border); }
.ring-progress { stroke: url(#ringGradient); transition: stroke-dashoffset 1s linear; }
.ring-center { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.ring-center .time { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 500; letter-spacing: -0.5px; color: var(--text-primary); }
.ring-center .label { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; margin-top: 4px; text-transform: uppercase; color: var(--text-muted); }
.status-card h2 { font-size: 1.15rem; margin-bottom: 2px; }
.status-card .building-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.3px; margin-bottom: 4px; }
.status-card .status-sub { font-size: 0.85rem; color: var(--text-secondary); }

/* ============ EMPLOYEE BOTTOM TAB BAR ============ */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 460px;
  margin: 0 auto;
  height: 82px;
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-top: 1px solid var(--surface-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding-top: 12px;
  z-index: 100;
}
.tabbar .tab { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-muted); }
.tabbar .tab.active { color: var(--accent-text-on-soft); }
.tabbar .tab svg { width: 24px; height: 24px; }
.tabbar .tab .tlabel { font-size: 10px; font-weight: 700; }

.text-muted { color: var(--text-secondary); }
.text-danger { color: var(--danger); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.small { font-size: 0.85rem; }

@media print {
  .theme-toggle { display: none; }
}
