@import "tailwindcss";

:root {
  --background: #f4f6f8;
  --foreground: #162033;
  --muted: #65758b;
  --line: #d9e0e8;
  --panel: #ffffff;
  --dark: #172033;
  --brand: #0f766e;
  --warn: #b45309;
}

@theme inline {
  --color-background: var(--background);
  --color-foreground: var(--foreground);
  --font-sans: var(--font-geist-sans);
  --font-mono: var(--font-geist-mono);
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #111827;
  cursor: pointer;
}

button:hover {
  background: #f8fafc;
  border-color: #94a3b8;
}

input,
select {
  min-height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #111827;
}

input {
  padding: 0 10px;
}

.app-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100vh;
  padding: 10px 12px;
}

.app-header,
.command-row,
.metrics,
.board,
.admin-login-panel,
.setup-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
}

.kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #111827;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  color: #111827;
  font-size: 16px;
}

.period-box {
  display: grid;
  grid-template-columns: 40px minmax(150px, auto) 40px;
  align-items: center;
  gap: 8px;
}

.period-box strong {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  text-align: center;
}

.period-box button {
  font-size: 24px;
}

.command-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tabs button,
.actions button {
  padding: 0 12px;
  font-weight: 700;
}

.tabs .active {
  border-color: var(--brand);
  background: #e7f5f1;
  color: #065f46;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.actions select {
  min-width: 180px;
  padding: 0 8px;
}

.admin-login-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.admin-login-panel p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.admin-login-form {
  justify-content: flex-end;
}

.admin-login-form input {
  min-width: 210px;
}

.admin-login-form button {
  padding: 0 12px;
  font-weight: 700;
}

.admin-locked .command-row,
.admin-locked .metrics,
.admin-locked .board,
.admin-locked .setup-grid {
  display: none;
}

.app-shell:not(.admin-locked) .admin-login-panel {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.public-note,
.view-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.metrics div {
  min-height: 58px;
  padding: 10px 14px;
  background: #fff;
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.metrics b {
  display: block;
  margin-top: 4px;
  color: #111827;
  font-size: 24px;
}

.board {
  overflow: hidden;
}

.board-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.board-title p {
  color: var(--muted);
  font-size: 12px;
}

.table-scroll {
  max-height: calc(100vh - 230px);
  overflow: auto;
}

.shift-table,
.year-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.shift-table th,
.shift-table td,
.year-table th,
.year-table td {
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
  text-align: center;
}

.shift-table thead th,
.year-table thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  min-width: 54px;
  padding: 7px 4px;
  background: var(--dark);
  color: #fff;
}

.shift-table thead th small {
  display: block;
  margin-top: 2px;
  color: #cbd5e1;
  font-size: 10px;
}

.shift-table thead th.weekend {
  background: var(--warn);
}

.person-col {
  position: sticky;
  left: 0;
  z-index: 5;
  min-width: 185px;
  max-width: 185px;
  text-align: left;
}

thead .person-col {
  background: #0f172a;
}

.person {
  padding: 6px 10px;
  background: #f8fafc;
}

.person b,
.person small {
  display: block;
}

.person small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.shift-table td {
  width: 54px;
  height: 34px;
  padding: 3px;
}

.shift-table td.weekend-off {
  background: #ffffff;
}

.shift-table td select {
  min-height: 26px;
  width: 100%;
  padding: 0 4px;
  border-color: color-mix(in srgb, var(--cell) 45%, white);
  background: color-mix(in srgb, var(--cell) 14%, white);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
}

.shift-table td.weekend-off select,
.shift-table td.weekend-off .shift-badge {
  border-color: #ef4444;
  background: #dc2626;
  color: #ffffff;
}

.shift-table td.n12-night-ok select,
.shift-table td.n12-night-ok .shift-badge {
  border-color: #d97706;
  background: #facc15;
  color: #111827;
}

.shift-table td.n14-shift select,
.shift-table td.n14-shift .shift-badge {
  border-color: #15803d;
  background: #16a34a;
  color: #ffffff;
}

.shift-table td.official-holiday select,
.shift-table td.official-holiday .shift-badge {
  border-color: #0284c7;
  background: #0ea5e9;
  color: #ffffff;
}

.shift-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 26px;
  border: 1px solid color-mix(in srgb, var(--cell) 45%, white);
  border-radius: 5px;
  background: color-mix(in srgb, var(--cell) 16%, white);
  color: #111827;
  font-size: 11px;
  font-weight: 800;
}

.total-col,
.total {
  min-width: 74px;
  background: #ecfdf5;
  color: #065f46;
  font-weight: 800;
}

.year-table td,
.year-table th {
  min-width: 76px;
  padding: 11px 8px;
}

.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 14px;
}

.setup-card {
  display: grid;
  gap: 10px;
  padding: 10px 14px;
}

.panel-help {
  color: var(--muted);
  font-size: 13px;
}

.legend-card {
  margin-top: 0;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}

.shift-form {
  grid-template-columns: 80px 1fr 120px 120px 52px auto;
}

.bulk-card {
  grid-column: 1 / -1;
}

.bulk-form {
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) 150px 170px 190px auto;
}

.weekend-form {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) 150px auto auto auto;
}

.n14-form {
  grid-template-columns: minmax(190px, 240px) auto;
  justify-content: start;
}

.field-label {
  display: grid;
  gap: 5px;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.check-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.check-control input {
  min-height: auto;
  width: auto;
}

.inline-form button {
  padding: 0 14px;
  font-weight: 700;
}

.chips,
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.employee-chip {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
}

.chips button {
  border: 0;
  border-radius: 0;
  padding: 0 10px;
  color: #334155;
  font-size: 12px;
}

.chips .remove-chip {
  border-left: 1px solid #cbd5e1;
  background: #fff1f2;
  color: #9f1239;
  font-weight: 800;
}

.group-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.group-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 120px;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}

.group-row .check-control {
  justify-content: center;
}

.group-row strong {
  color: #111827;
  font-size: 13px;
}

.group-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid #e2e8f0;
  border-left: 5px solid var(--dot);
  border-radius: 6px;
  background: #fff;
  color: #475569;
  font-size: 11px;
}

.legend b {
  color: #111827;
}

.remove-shift {
  min-height: 24px;
  margin-left: 4px;
  padding: 0 8px;
  border-color: #fecdd3;
  background: #fff1f2;
  color: #9f1239;
  font-size: 11px;
  font-weight: 800;
}

@media (max-width: 900px) {
  .app-header,
  .command-row,
  .board-title {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .setup-grid {
    grid-template-columns: 1fr 1fr;
  }

  .inline-form,
  .shift-form {
    grid-template-columns: 1fr;
  }

  .table-scroll {
    max-height: 68vh;
  }
}

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

  h1 {
    font-size: 24px;
  }

  .metrics,
  .setup-grid {
    grid-template-columns: 1fr;
  }

  .period-box {
    grid-template-columns: 38px 1fr 38px;
  }

  .actions {
    flex-direction: column;
  }
}
