/* =========================================================
   Tính công vân tay — styles.css
   ========================================================= */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --warn: #b45309;
  --warn-soft: #fff7ed;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --success: #047857;
  --success-soft: #ecfdf5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.05);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.is-busy {
  cursor: progress;
}

/* ───────── Header ───────── */

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.app-header__inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.app-header__title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header__title h1 {
  font-size: 19px;
  margin: 0;
  letter-spacing: -0.01em;
}

.app-header__title p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--primary-soft);
  font-size: 20px;
}

/* ───────── Layout ───────── */

.app-main {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.panel__head h2 {
  font-size: 15px;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.hint {
  font-size: 13px;
  color: var(--text-muted);
}

/* ───────── Drop zone ───────── */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 26px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #fbfdff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.drop-zone strong {
  color: var(--text);
  font-size: 15px;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
  outline: none;
}

.drop-zone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.drop-zone__icon {
  font-size: 26px;
}

.file-info {
  margin: 12px 0 0;
  padding: 10px 14px;
  background: var(--success-soft);
  border: 1px solid #a7f3d0;
  border-radius: 10px;
  font-size: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--success);
}

.file-info span {
  color: var(--text-muted);
  font-size: 13px;
}

/* ───────── Form ───────── */

.form-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.field > span {
  font-weight: 600;
}

.field input[type='number'],
.field select {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
}

.field input[type='number']:focus,
.field select:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--primary);
}

.field input:disabled,
.field select:disabled {
  background: #f1f5f9;
  color: var(--text-muted);
}

.field--check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fbfdff;
  color: var(--text);
}

.field--check input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.field--action {
  justify-content: flex-end;
}

/* ───────── Buttons ───────── */

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  height: 38px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
  height: 42px;
  padding: 0 20px;
}

.btn--primary:hover:not(:disabled) {
  background: var(--primary-dark);
}

.btn--primary:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

.btn--ghost {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.btn--ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ───────── Alerts / notes ───────── */

.alert {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--danger);
  font-size: 14px;
}

.notes-wrap {
  margin-top: 12px;
}

.notes {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

.notes li + li {
  margin-top: 3px;
}

.placeholder {
  color: var(--text-muted);
  font-size: 14px;
  margin: 8px 0;
}

/* ───────── Stats ───────── */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fbfdff;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat__value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat__label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat--warn {
  background: var(--warn-soft);
  border-color: #fed7aa;
}

.stat--warn .stat__value {
  color: var(--warn);
}

/* ───────── Tables ───────── */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  max-height: 620px;
}

.table-wrap--short {
  max-height: 340px;
}

.grid {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  width: 100%;
  white-space: nowrap;
}

.grid th,
.grid td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #eef2f7;
  text-align: center;
}

.grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f1f5f9;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-strong);
}

.grid tbody tr:nth-child(even) {
  background: #fcfdff;
}

.grid tbody tr:hover {
  background: var(--primary-soft);
}

.grid td:nth-child(n + 4),
.grid th:nth-child(n + 4) {
  min-width: 62px;
}

/* Cột 3 cột đầu cố định khi cuộn ngang */
.grid--pivot .sticky-col {
  position: sticky;
  background: inherit;
  z-index: 2;
  text-align: left;
}

.grid--pivot thead .sticky-col {
  z-index: 4;
  background: #f1f5f9;
}

.grid--pivot tbody tr:nth-child(even) .sticky-col {
  background: #fcfdff;
}

.grid--pivot tbody tr:hover .sticky-col {
  background: var(--primary-soft);
}

.grid--pivot .col-1 {
  left: 0;
  min-width: 86px;
  font-weight: 600;
}

.grid--pivot .col-2 {
  left: 86px;
  min-width: 180px;
  text-align: left;
}

.grid--pivot .col-3 {
  left: 266px;
  min-width: 140px;
  text-align: left;
  box-shadow: 2px 0 0 var(--border);
}

.cell--code {
  color: var(--primary-dark);
  font-weight: 600;
}

.cell--hours {
  color: var(--warn);
}

.cell--empty {
  color: #cbd5e1;
}

.cell--total {
  font-weight: 700;
  background: #f8fafc;
  border-left: 1px solid var(--border-strong);
}

.total-head {
  background: #e2e8f0 !important;
  color: var(--text) !important;
}

.cell--missing {
  color: var(--danger);
  font-weight: 600;
}

/* ───────── Loading / footer ───────── */

.loading {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: grid;
  place-items: center;
  z-index: 50;
}

.loading[hidden] {
  display: none;
}

.loading__box {
  background: #fff;
  border-radius: 12px;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.2);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.app-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 18px 24px 28px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ───────── Cảnh báo file:// ───────── */

.protocol-warning {
  margin: 0;
  padding: 18px 24px;
  background: var(--warn-soft);
  border-bottom: 1px solid #fed7aa;
  color: var(--warn);
}

.protocol-warning h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.protocol-warning p {
  margin: 0;
  font-size: 14px;
}

.protocol-warning code {
  background: #fff;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid #fed7aa;
}

/* ───────── Responsive ───────── */

@media (max-width: 720px) {
  .app-main {
    padding: 14px;
  }

  .panel {
    padding: 14px;
  }

  .app-header__inner {
    padding: 12px 14px;
  }

  .app-header__actions .btn {
    width: 100%;
  }

  .grid--pivot .col-2 {
    left: 86px;
    min-width: 130px;
  }

  .grid--pivot .col-3 {
    display: none;
  }
}
