:root {
  color-scheme: light;
  --navy: #15314b;
  --navy-2: #0e2438;
  --blue: #2464a6;
  --green: #18794e;
  --green-soft: #e9f7f0;
  --orange: #b85c00;
  --orange-soft: #fff3df;
  --red: #b42318;
  --red-soft: #fff0ee;
  --surface: #ffffff;
  --surface-2: #f4f7fa;
  --border: #d8e0e8;
  --text: #15212c;
  --muted: #637180;
  --shadow: 0 16px 40px rgba(15, 35, 54, .11);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--surface-2); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #edf3f8 0, #f7f9fb 330px, #f4f7fa 100%);
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; filter: grayscale(.2); }
[hidden] { display: none !important; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand span:last-child { display: grid; line-height: 1.1; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); margin-top: 4px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, var(--navy), var(--blue));
  font-weight: 850;
  letter-spacing: -.04em;
  box-shadow: 0 8px 18px rgba(21, 49, 75, .22);
}

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid rgba(216, 224, 232, .85);
  border-radius: 24px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.brand-login { margin-bottom: 30px; }
h1, h2, p { margin-top: 0; }
.login-card h1 { margin-bottom: 8px; font-size: clamp(28px, 6vw, 38px); letter-spacing: -.04em; }
.muted { color: var(--muted); }
label { display: block; margin: 18px 0 7px; font-size: 14px; font-weight: 720; }
input, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 13px 14px;
  outline: none;
  transition: border .15s, box-shadow .15s;
}
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(36,100,166,.12); }
.form-error { margin-top: 14px; color: var(--red); font-weight: 650; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 760;
  transition: transform .12s, box-shadow .12s, background .12s;
}
.button:not(:disabled):active { transform: translateY(1px); }
.button.primary { color: #fff; background: var(--navy); box-shadow: 0 8px 20px rgba(21,49,75,.17); }
.button.secondary { color: var(--navy); border-color: var(--border); background: #fff; }
.button.ghost { color: var(--navy); border-color: var(--border); background: transparent; }
.button.wide { width: 100%; margin-top: 24px; }
.button.small { min-height: 36px; padding: 7px 12px; font-size: 13px; }

.app-shell { min-height: 100vh; }
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 76px;
  padding: 12px max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid rgba(216,224,232,.92);
  background: rgba(255,255,255,.91);
  backdrop-filter: blur(16px);
}
.user-box { display: flex; align-items: center; gap: 12px; font-weight: 750; }
.tabs {
  display: flex;
  gap: 6px;
  padding: 13px max(20px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--border);
  background: rgba(244,247,250,.86);
  overflow-x: auto;
}
.tab {
  min-width: 104px;
  padding: 10px 16px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-weight: 780;
}
.tab.active { color: #fff; background: var(--navy); }
.content { width: min(1180px, calc(100% - 32px)); margin: 24px auto 60px; }
.tab-panel { display: grid; gap: 20px; }

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 188px;
  padding: clamp(24px, 5vw, 38px);
  border-radius: 24px;
  color: #fff;
  box-shadow: var(--shadow);
}
.status-card h1 { margin: 5px 0 8px; font-size: clamp(30px, 6vw, 48px); letter-spacing: -.045em; }
.status-card p { margin: 0; color: rgba(255,255,255,.8); }
.status-off { background: linear-gradient(135deg, #4d5b67, #263847); }
.status-working { background: linear-gradient(135deg, #196b49, #0e4f38); }
.status-paused { background: linear-gradient(135deg, #b86509, #824003); }
.live-timer { font-variant-numeric: tabular-nums; font-size: clamp(30px, 7vw, 56px); font-weight: 850; letter-spacing: -.04em; white-space: nowrap; }
.eyebrow { display: block; text-transform: uppercase; letter-spacing: .11em; font-size: 11px; font-weight: 850; opacity: .72; }

.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.action-button {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 112px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: left;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 8px 25px rgba(21,49,75,.07);
}
.action-button:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(21,49,75,.11); }
.action-button strong, .action-button small { display: block; }
.action-button strong { font-size: 18px; }
.action-button small { margin-top: 4px; color: var(--muted); }
.action-icon { display: grid; place-items: center; flex: 0 0 48px; height: 48px; border-radius: 14px; color: #fff; font-weight: 900; }
.start .action-icon, .resume .action-icon { background: var(--green); }
.pause .action-icon { background: var(--orange); }
.stop .action-icon { background: var(--red); }

.notice { padding: 14px 16px; border-radius: 13px; border: 1px solid; line-height: 1.45; }
.notice.info { color: #174d7d; border-color: #bcd8ef; background: #eef7ff; }
.notice.warning { color: #7b3e00; border-color: #f0cf9a; background: var(--orange-soft); }
.card { padding: clamp(20px, 4vw, 30px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 9px 28px rgba(21,49,75,.06); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 22px; margin-bottom: 20px; }
.section-heading.wrap { flex-wrap: wrap; }
.section-heading h1, .section-heading h2 { margin: 4px 0 0; letter-spacing: -.035em; }
.hours-large { font-size: clamp(26px, 5vw, 38px); color: var(--navy); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-row > div { padding: 14px; border-radius: 13px; background: var(--surface-2); }
.stat-row span, .stat-row strong { display: block; }
.stat-row span { color: var(--muted); font-size: 13px; }
.stat-row strong { margin-top: 5px; font-size: 20px; }
.period-controls { display: grid; grid-template-columns: auto auto auto; align-items: end; gap: 8px; }
.period-controls label { grid-column: 1 / -1; margin: 0; }
.period-controls input { min-width: 165px; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; }
.summary-box { padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); }
.summary-box span, .summary-box strong { display: block; }
.summary-box span { color: var(--muted); font-size: 13px; }
.summary-box strong { margin-top: 7px; font-size: 25px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.table-card { padding-bottom: 10px; }
.table-wrap { overflow-x: auto; margin: 0 -10px; padding: 0 10px 12px; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:hover { background: #f8fafc; }
.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 9px; border-radius: 99px; font-size: 12px; font-weight: 790; }
.badge.ok { color: #11643f; background: var(--green-soft); }
.badge.warn { color: #884400; background: var(--orange-soft); }
.badge.off { color: #4e5c68; background: #edf1f4; }
.row-actions { display: flex; gap: 6px; }
.link-button { padding: 5px 8px; border: 0; border-radius: 8px; color: var(--blue); background: #eef6ff; font-weight: 720; }
.map-link { color: var(--blue); font-weight: 700; text-decoration: none; }

.employee-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.employee-card { padding: 17px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface-2); }
.employee-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: start; }
.employee-card h3 { margin: 0; }
.employee-card p { margin: 10px 0 0; color: var(--muted); }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: min(520px, calc(100% - 32px));
  padding: 13px 18px;
  border-radius: 12px;
  color: #fff;
  background: var(--navy-2);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }
.busy-overlay, .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10,25,38,.58);
  backdrop-filter: blur(4px);
}
.busy-overlay { color: #fff; align-content: center; gap: 14px; }
.spinner { width: 42px; height: 42px; border: 4px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; padding: 24px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); }
.modal-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-header h2 { margin: 0; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 10px; font-size: 26px; color: var(--muted); background: var(--surface-2); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
.audit-list { display: grid; gap: 10px; margin-top: 18px; }
.audit-item { padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.audit-item strong, .audit-item span { display: block; }
.audit-item span { margin-top: 4px; color: var(--muted); font-size: 13px; }

@media (max-width: 720px) {
  .app-header { min-height: 68px; }
  .brand strong { font-size: 14px; }
  .user-box > span { display: none; }
  .content { width: min(100% - 20px, 1180px); margin-top: 14px; }
  .status-card { align-items: flex-start; flex-direction: column; min-height: 210px; }
  .live-timer { align-self: flex-end; }
  .action-grid { grid-template-columns: 1fr; }
  .action-button { min-height: 92px; }
  .stat-row { grid-template-columns: 1fr; }
  .period-controls { grid-template-columns: 1fr; width: 100%; }
  .period-controls input { min-width: 0; }
  .section-heading { align-items: flex-start; }
}

@media print {
  body { background: #fff; }
  .app-header, .tabs, #clockTab, #officeTab, .toolbar, .period-controls, .button, .toast { display: none !important; }
  #appView, #monthTab { display: block !important; }
  .content { width: 100%; margin: 0; }
  .card { border: 0; box-shadow: none; padding: 10px 0; }
  .table-wrap { overflow: visible; }
  table { white-space: normal; }
}
