:root {
  color-scheme: light;
  --ink: #102033;
  --muted: #607089;
  --line: #c8d5e5;
  --surface: #ffffff;
  --soft: #eef5ff;
  --brand: #0759b8;
  --brand-dark: #043f88;
  --brand-deep: #062d63;
  --accent: #1d75d8;
  --danger: #b91c1c;
  --gold: #c3922e;
  --shadow: 0 18px 44px rgba(7, 34, 76, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(7, 89, 184, 0.16), transparent 38%),
    linear-gradient(90deg, rgba(6, 45, 99, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(6, 45, 99, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, #f4f8ff 0%, #eef4fb 46%, #ffffff 100%);
  background-size: auto, 28px 28px, 28px 28px, auto;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(100%, 1120px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px;
}

.login-view {
  display: grid;
  align-content: center;
  min-height: 100vh;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand-deep), var(--brand));
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

.brand h1,
.topbar h1 {
  font-size: 30px;
}

.brand p,
.muted,
.hint {
  color: var(--muted);
}

.brand p {
  color: rgba(255, 255, 255, 0.78);
}

.panel,
.content-panel,
.status-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: #ffffff;
}

input:focus {
  outline: 3px solid rgba(7, 89, 184, 0.18);
  border-color: var(--brand);
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  box-shadow: 0 10px 20px rgba(7, 89, 184, 0.22);
}

.primary-button:hover {
  background: var(--brand-dark);
}

.secondary-button,
.icon-button {
  color: var(--brand-deep);
  background: var(--soft);
  border: 1px solid var(--line);
}

.compact {
  min-height: 38px;
  padding: 0 12px;
}

.staff-view {
  display: grid;
  gap: 18px;
  padding: 10px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand-deep), #0b63c7);
  box-shadow: var(--shadow);
}

.topbar .muted {
  color: rgba(255, 255, 255, 0.76);
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 22px rgba(7, 34, 76, 0.08);
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wide-field {
  grid-column: 1 / -1;
}

.tab {
  color: var(--muted);
  background: transparent;
}

.tab.active {
  color: #ffffff;
  background: var(--brand-deep);
}

.content-panel {
  display: grid;
  gap: 16px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}

.content-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand-deep), var(--accent), var(--gold));
}

.status-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  box-shadow: none;
  background: #f8fbfb;
  border-left: 4px solid var(--brand);
}

.status-card h2 {
  font-size: 24px;
}

.status-text {
  color: var(--brand);
  font-weight: 700;
}

.note-field {
  color: var(--muted);
}

.camera-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid #b7c8dd;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff, #ffffff);
}

#cameraPreview,
.photo-preview {
  width: 100%;
  max-height: 420px;
  aspect-ratio: 4 / 3;
  border: 2px solid #8fb0d8;
  border-radius: 8px;
  background: #111827;
  object-fit: cover;
}

.attendance-info {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.attendance-info div {
  min-width: 0;
  padding: 10px;
  border: 1px solid #c6d7eb;
  border-radius: 8px;
  background: #eef5ff;
}

.attendance-info span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.attendance-info strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
  color: var(--brand-deep);
  font-size: 13px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.checkin-button {
  min-height: 58px;
  font-size: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.section-heading h2 {
  font-size: 22px;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item {
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(7, 34, 76, 0.06);
}

.list-item strong {
  font-size: 16px;
}

.meta {
  color: var(--muted);
  font-size: 14px;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid #9eb6d4;
  border-radius: 8px;
  background: #ffffff;
}

.history-table {
  width: 100%;
  min-width: 560px;
  border-collapse: separate;
  border-spacing: 0;
}

.history-table th,
.history-table td {
  border-right: 1px solid #b7c8dd;
  border-bottom: 1px solid #b7c8dd;
  padding: 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

.history-table th:last-child,
.history-table td:last-child {
  width: 82px;
  text-align: center;
}

.history-table th {
  color: #ffffff;
  background: var(--brand-deep);
}

.history-table td {
  background: #ffffff;
}

.attendance-thumb-link {
  display: inline-flex;
  width: 56px;
  height: 56px;
}

.attendance-thumb,
.history-table img.attendance-thumb {
  display: block;
  width: 56px !important;
  height: 56px !important;
  max-width: 56px !important;
  max-height: 56px !important;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.schedule-table-wrap {
  overflow-x: auto;
  border: 2px solid #6388b5;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.schedule-table {
  width: 100%;
  min-width: 820px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.schedule-table th,
.schedule-table td {
  width: 102px;
  height: 34px;
  border-right: 1px solid #7f9fc4;
  border-bottom: 1px solid #7f9fc4;
  padding: 6px;
  text-align: center;
  vertical-align: middle;
  font-size: 13px;
}

.schedule-table tr:first-child th,
.schedule-table tr:nth-child(2) th,
.schedule-table tr:nth-child(3) th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #ffffff;
  background: var(--brand-deep);
}

.schedule-table th:first-child,
.schedule-table td:first-child {
  width: 92px;
  text-align: right;
  font-weight: 700;
  color: var(--brand-deep);
  background: #eaf2fd;
  position: sticky;
  left: 0;
  z-index: 2;
}

.schedule-label {
  text-align: left !important;
  color: #ffffff !important;
  background: var(--brand-deep) !important;
}

.duty-cell {
  color: #ffffff;
  background: linear-gradient(135deg, #0b63c7, #2984e6);
  font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24);
}

.schedule-table tr:nth-child(even) td:not(.duty-cell) {
  background: #f6f9fe;
}

.late-text {
  color: var(--danger);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  padding: 13px 15px;
  border-radius: 8px;
  color: #ffffff;
  background: var(--ink);
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 560px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand h1,
  .topbar h1 {
    font-size: 25px;
  }

  .tab {
    padding: 0 8px;
    font-size: 14px;
  }

  .attendance-info {
    grid-template-columns: 1fr;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }
}
