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

:root {
  color-scheme: light;
  --navy: #111c3d;
  --navy-soft: #1a2852;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a36a;
  --amber: #e79513;
  --red: #e44949;
  --purple: #7559e8;
  --ink: #17203b;
  --muted: #74809a;
  --border: #e7eaf1;
  --surface: #ffffff;
  --background: #f5f7fb;
  --shadow: 0 16px 40px rgba(25, 38, 73, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--background);
  color: var(--ink);
  font-family: Inter, "Noto Sans Khmer", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.4);
  opacity: 0.55;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: 252px;
  flex-direction: column;
  padding: 26px 18px;
  background: linear-gradient(180deg, var(--navy), #0d1631);
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px 28px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 43px;
  height: 43px;
  place-items: center;
  border-radius: 13px;
  background: var(--blue);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
}

.brand small {
  margin-top: 3px;
  color: #9ba7c6;
  font-size: 11px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a,
.side-nav button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #aab4d0;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  transition: 0.2s ease;
}

.side-nav a:hover,
.side-nav button:hover,
.side-nav a.active {
  background: var(--navy-soft);
  color: #fff;
}

.side-nav a.active {
  box-shadow: inset 3px 0 var(--blue);
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 15px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-footer strong,
.sidebar-footer small {
  display: block;
}

.sidebar-footer strong {
  font-size: 12px;
}

.sidebar-footer small {
  margin-top: 2px;
  color: #97a4c4;
  font-size: 10px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #29c982;
  box-shadow: 0 0 0 4px rgba(41, 201, 130, 0.15);
}

.main-content {
  width: calc(100% - 252px);
  max-width: 1540px;
  min-height: 100vh;
  margin-left: 252px;
  padding: 36px 42px 54px;
}

.topbar,
.section-heading,
.today-card,
.topbar-actions,
.today-actions {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 28px;
}

.topbar h1 {
  margin: 2px 0 7px;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.035em;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-family: "Noto Sans Khmer", Inter, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  gap: 12px;
}

.connection-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid #d8e0ee;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.connection-pill span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #a4adbd;
}

.connection-pill.online {
  border-color: #bcebd6;
  color: #137852;
}

.connection-pill.online span {
  background: #20b979;
  box-shadow: 0 0 0 3px rgba(32, 185, 121, 0.14);
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
  color: #687590;
}

.today-card {
  justify-content: space-between;
  gap: 30px;
  padding: 28px 32px;
  overflow: hidden;
  border-radius: 20px;
  background:
    radial-gradient(circle at 60% -30%, rgba(74, 124, 255, 0.5), transparent 34%),
    linear-gradient(118deg, #172856, #102042);
  box-shadow: 0 18px 45px rgba(21, 38, 82, 0.2);
  color: #fff;
}

.section-label {
  color: #92aaf0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.today-copy h2 {
  margin: 8px 0 7px;
  font-size: clamp(36px, 5vw, 50px);
  letter-spacing: -0.045em;
}

.today-copy p {
  margin: 0;
  color: #aebce0;
  font-size: 12px;
}

.today-actions {
  justify-content: flex-end;
  gap: 14px;
}

.action-block {
  display: grid;
  gap: 7px;
  text-align: center;
}

.action-block small {
  min-height: 14px;
  color: #aebce0;
  font-size: 10px;
}

.primary-action,
.secondary-action {
  display: flex;
  min-width: 145px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 14px 18px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.primary-action:hover:not(:disabled),
.secondary-action:hover:not(:disabled) {
  transform: translateY(-2px);
}

.primary-action.check-in {
  background: var(--blue);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.28);
}

.primary-action.check-out {
  background: #fff;
  color: #24365d;
}

.secondary-action {
  min-width: auto;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
}

.summary-section {
  padding: 32px 0;
}

.section-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 4px 0 0;
  font-size: 19px;
  letter-spacing: -0.025em;
}

input[type="month"] {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

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

.stat-card {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 7px 24px rgba(27, 39, 77, 0.04);
}

.stat-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 12px;
}

.stat-icon svg {
  width: 20px;
  height: 20px;
}

.stat-icon.green {
  background: #e8f8f1;
  color: var(--green);
}

.stat-icon.amber {
  background: #fff5df;
  color: var(--amber);
}

.stat-icon.red {
  background: #ffeded;
  color: var(--red);
}

.stat-icon.blue {
  background: #eaf1ff;
  color: var(--blue);
}

.stat-icon.purple {
  background: #f0edff;
  color: var(--purple);
}

.stat-card strong,
.stat-card span {
  display: block;
}

.stat-card strong {
  overflow: hidden;
  font-size: 25px;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
}

.stat-card div > span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.history-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 17px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.history-card > .section-heading {
  margin: 0;
  padding: 21px 24px;
  border-bottom: 1px solid var(--border);
}

.record-count {
  padding: 7px 10px;
  border-radius: 8px;
  background: #f1f4f9;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

th {
  padding: 12px 20px;
  background: #fafbfc;
  color: #8c96aa;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  padding: 15px 20px;
  border-top: 1px solid #f0f2f6;
  color: #4d5870;
  white-space: nowrap;
}

td:first-child {
  color: var(--ink);
  font-weight: 600;
}

.date-cell small {
  display: block;
  margin-top: 3px;
  color: #98a2b4;
  font-size: 9px;
  font-weight: 500;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
}

.status-badge::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-on_time {
  background: #e9f8f1;
  color: #16845b;
}

.status-late {
  background: #fff4dc;
  color: #b87409;
}

.status-absent {
  background: #ffeded;
  color: #c83939;
}

.status-day_off {
  background: #edf2ff;
  color: #315ec5;
}

.status-pending {
  background: #f0f2f6;
  color: #68748a;
}

.row-delete {
  border: 0;
  background: transparent;
  color: #9aa4b7;
  font-size: 16px;
}

.row-delete:hover {
  color: var(--red);
}

.empty-state {
  padding: 50px 20px;
  text-align: center;
}

.empty-state span {
  font-size: 38px;
}

.empty-state h3 {
  margin: 13px 0 5px;
  font-size: 15px;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

dialog {
  width: min(560px, calc(100% - 30px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(9, 16, 36, 0.62);
  backdrop-filter: blur(3px);
}

.dialog-card {
  display: grid;
  gap: 20px;
  padding: 27px;
  border-radius: 18px;
  background: #fff;
}

.dialog-card.compact {
  width: 100%;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.dialog-header h2 {
  margin: 4px 0 0;
  font-size: 21px;
}

.dialog-close {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: #f2f4f8;
  color: #667085;
  font-size: 21px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

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

.dialog-card > label,
.form-grid label {
  display: grid;
  gap: 8px;
  color: #39445c;
  font-size: 11px;
  font-weight: 700;
}

.dialog-card input,
.dialog-card textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #dce1ea;
  border-radius: 9px;
  outline: none;
  background: #fff;
  color: var(--ink);
}

.dialog-card input:focus,
.dialog-card textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dialog-card label small {
  color: #8a94a8;
  font-size: 9px;
  font-weight: 500;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  color: #39445c;
  font-size: 11px;
  font-weight: 700;
}

.day-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.day-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid #dce1ea;
  border-radius: 8px;
  color: #59657c;
  font-size: 10px;
  font-weight: 600;
}

.day-options input {
  width: auto;
  accent-color: var(--blue);
}

.telegram-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px;
  border: 1px solid #dfe8fb;
  border-radius: 11px;
  background: #f6f9ff;
}

.telegram-box strong {
  font-size: 11px;
}

.telegram-box p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.outline-button,
.save-button,
.text-button {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
}

.outline-button {
  border: 1px solid #bfcdf0;
  background: #fff;
  color: var(--blue);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding-top: 4px;
}

.text-button {
  border: 0;
  background: transparent;
  color: #6e7890;
}

.save-button {
  border: 0;
  background: var(--blue);
  color: #fff;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(380px, calc(100% - 48px));
  padding: 13px 16px;
  border-radius: 11px;
  background: #152044;
  box-shadow: 0 16px 35px rgba(13, 23, 49, 0.28);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #b83232;
}

@media (max-width: 1120px) {
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .today-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .today-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 780px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 15px 18px;
    flex-direction: row;
    align-items: center;
  }

  .brand {
    padding: 0;
  }

  .brand small,
  .sidebar-footer,
  .side-nav a span {
    display: none;
  }

  .side-nav {
    display: flex;
    margin-left: auto;
  }

  .side-nav a,
  .side-nav button {
    width: 42px;
    height: 42px;
    justify-content: center;
    padding: 0;
    font-size: 0;
  }

  .main-content {
    width: 100%;
    margin-left: 0;
    padding: 25px 18px 40px;
  }

  .today-actions {
    flex-wrap: wrap;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

  .connection-pill {
    display: none;
  }

  .today-card {
    padding: 24px 20px;
  }

  .today-actions,
  .action-block,
  .primary-action,
  .secondary-action {
    width: 100%;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

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

  .telegram-box {
    align-items: flex-start;
    flex-direction: column;
  }
}
