:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #19212a;
  --muted: #697584;
  --line: #dce2e8;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #c2410c;
  --danger-bg: #fff3ed;
  --positive: #087f5b;
  --negative: #b42318;
  --shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

textarea {
  resize: vertical;
  line-height: 1.5;
  padding: 10px;
}

.work-note {
  min-height: 118px;
  border-width: 2px;
  background: #fffdf7;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

main {
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(8, 127, 91, 0.12), transparent 34%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 17px;
}

.hint,
.panel-head p,
.empty,
.list-row span {
  color: var(--muted);
}

.hint {
  margin: 0;
  font-size: 13px;
}

.topbar,
.toolbar,
.panel,
.list-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.userbar,
.toolbar,
.row-actions,
.inline-form,
.account-form {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar {
  margin: 18px 0;
  padding: 14px;
  flex-wrap: wrap;
}

.toolbar label {
  width: 180px;
}

.toolbar .search-field {
  width: 220px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  background: #e7f7ef;
  color: var(--positive);
  font-size: 13px;
  font-weight: 700;
}

.badge.muted {
  background: #eef1f4;
  color: var(--muted);
}

.primary {
  background: var(--primary);
  color: white;
}

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

.secondary {
  background: #e8eefc;
  color: var(--primary-dark);
}

.ghost {
  background: #eef1f4;
  color: #334155;
}

.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.link-button {
  min-height: auto;
  border-radius: 4px;
  padding: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  text-align: left;
}

.link-button:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.icon-button {
  width: 38px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.wide {
  width: 100%;
}

.message {
  margin: 0 0 14px;
  border-radius: 6px;
  padding: 10px 12px;
  background: #edf7f2;
  color: var(--positive);
}

.message.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(360px, 0.8fr);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.side {
  display: grid;
  gap: 18px;
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.quick-stats div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
}

.quick-stats span,
.quick-stats strong {
  display: block;
}

.quick-stats span {
  color: var(--muted);
  font-size: 12px;
}

.quick-stats strong {
  margin-top: 6px;
  font-size: 22px;
}

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head p {
  margin: 4px 0 0;
  font-size: 13px;
}

.summary-panel {
  min-width: 0;
}

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

table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  color: #475569;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

td:last-child,
th:last-child {
  border-right: 0;
}

.sticky-left {
  position: sticky;
  left: 0;
  z-index: 3;
  background: inherit;
  min-width: 120px;
}

td.sticky-left {
  background: #fff;
}

.sticky-left small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.positive {
  color: var(--positive);
  font-weight: 700;
}

.negative {
  color: var(--negative);
  font-weight: 700;
}

.empty {
  text-align: center;
  padding: 24px;
}

.empty.compact {
  padding: 12px 0 0;
  margin: 0;
}

.panel form {
  display: grid;
  gap: 12px;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto auto auto;
  margin-bottom: 12px;
}

.employee-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1.25fr 150px;
  gap: 14px;
  align-items: end;
}

.form-group {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.form-group h3 {
  margin: 0;
  color: #334155;
  font-size: 13px;
}

.check-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-submit {
  min-width: 0;
}

.account-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto auto auto;
  margin-bottom: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.check input {
  width: 16px;
  min-height: 16px;
}

.check span {
  margin: 0;
  color: var(--text);
}

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

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

.list-row strong,
.list-row span {
  display: block;
}

.employee-list {
  display: grid;
  gap: 12px;
}

.employee-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(360px, auto);
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.employee-main {
  min-width: 0;
}

.employee-title,
.employee-meta,
.employee-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.employee-title strong {
  font-size: 16px;
}

.employee-meta {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.off {
  background: #f1f5f9;
  color: #64748b;
}

.status-pill.accent {
  background: #e7f7ef;
  color: var(--positive);
}

.employee-actions {
  justify-content: flex-end;
}

.employee-actions button {
  min-height: 34px;
  padding: 0 11px;
}

.compact-table {
  max-height: 420px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal {
  width: min(920px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.small-modal {
  width: min(460px, 100%);
}

.wide-modal {
  width: min(1080px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

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

.modal-form {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.log-filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  flex-wrap: wrap;
}

.log-filters label {
  width: 170px;
}

.log-filters .log-keyword {
  flex: 1;
  min-width: 240px;
}

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

.modal-list {
  overflow: auto;
  padding: 16px;
}

.modal-table {
  margin: 16px;
  max-height: 560px;
}

@media (max-width: 1100px) {
  .grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  main {
    width: min(100% - 20px, 1500px);
    padding-top: 12px;
  }

  .topbar,
  .userbar,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar label,
  .toolbar .search-field,
  .log-filters label,
  .log-filters .log-keyword,
  .log-filters button,
  .toolbar button,
  .userbar button {
    width: 100%;
  }

  h1 {
    font-size: 22px;
  }

  .inline-form,
  .account-form,
  .employee-form,
  .employee-row {
    grid-template-columns: 1fr;
  }

  .list-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .row-actions {
    width: 100%;
  }

  .row-actions button {
    flex: 1;
  }

  .employee-actions {
    justify-content: stretch;
  }

  .employee-actions button {
    flex: 1;
  }

  .quick-stats {
    grid-template-columns: 1fr;
  }
}
