:root {
  --ink: #18212f;
  --muted: #657385;
  --line: #d8e0e8;
  --panel: #ffffff;
  --bg: #f4f6f8;
  --brand: #12324a;
  --brand-2: #1d6b7a;
  --ok: #16734d;
  --warn: #9a5b13;
  --bad: #a23a32;
  --soft-ok: #e6f3ed;
  --soft-warn: #fff2dc;
  --soft-bad: #fbe7e5;
  --shadow: 0 10px 30px rgba(18, 50, 74, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

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

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  background: var(--brand);
  color: white;
}

.brand {
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 58px;
  height: 44px;
  object-fit: contain;
  background: #cf001b;
  border-radius: 6px;
  display: block;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-copy strong {
  font-size: 18px;
}

.brand-copy span,
.session span {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
}

.session {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
}

.logout {
  background: rgba(255, 255, 255, 0.13);
  color: white;
}

.page {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 20px;
}

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, #eef3f7 0%, #f8fafb 100%);
}

.login-card {
  width: min(420px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.login-logo {
  width: 112px;
  height: auto;
  display: block;
  margin: 0 0 16px;
  border-radius: 8px;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.install-app {
  display: none;
  width: 100%;
  margin: 0 0 14px;
}

.install-app.visible {
  display: block;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}

.field textarea {
  min-height: 96px;
  resize: vertical;
}

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

.secondary {
  background: #e9eef3;
  color: var(--ink);
}

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

.warning {
  background: var(--soft-warn);
  color: var(--warn);
}

.success {
  background: var(--soft-ok);
  color: var(--ok);
}

.error {
  min-height: 20px;
  color: var(--bad);
  font-size: 13px;
  font-weight: 700;
}

.toolbar,
.filters,
.actions,
.task-actions,
.summary-grid,
.admin-grid,
.split {
  display: grid;
  gap: 12px;
}

.toolbar {
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 16px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.toolbar p,
.section-title p {
  margin: 0;
  color: var(--muted);
}

.filters {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 16px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.workload-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.maid-filter {
  margin: 0 0 14px;
  max-width: 280px;
}

.reception-filter {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 14px;
  max-width: 840px;
}

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

.metric {
  padding: 14px;
}

.metric-button {
  width: 100%;
  min-height: 82px;
  text-align: left;
  cursor: pointer;
}

.metric-button:active {
  transform: translateY(1px);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
}

.workload-grid .metric {
  min-height: 82px;
}

.workload-grid .metric span {
  min-height: 28px;
}

.panel {
  padding: 16px;
}

.admin-grid {
  grid-template-columns: 1.1fr 1.9fr;
  align-items: start;
}

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

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

.reception-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.reception-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.apartment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px;
}

.apartment-tile {
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f6f8fa;
}

.apartment-tile strong {
  display: block;
  font-size: 24px;
}

.apartment-tile span,
.apartment-tile small {
  display: block;
  margin-top: 4px;
}

.apartment-tile span {
  font-weight: 700;
  font-size: 13px;
}

.apartment-tile small {
  color: var(--muted);
  font-size: 12px;
}

.apartment-tile em {
  display: block;
  margin-top: 6px;
  font-style: normal;
  font-size: 12px;
  font-weight: 700;
}

.client-left-btn {
  width: 100%;
  min-height: 34px;
  margin-top: 8px;
  padding: 0 8px;
  background: var(--brand-2);
  color: white;
  font-size: 12px;
}

.key-notice {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 8px 0 10px;
  padding: 10px;
  border: 1px solid #7db4f0;
  border-left: 4px solid #1f6fbf;
  border-radius: 8px;
  background: #dcecff;
}

.key-notice span {
  color: var(--muted);
  font-size: 13px;
}

.status-dot.done,
.apartment-tile.done {
  background: #dff3e9;
  border-color: #7fca9f;
}

.status-dot.progress,
.apartment-tile.progress {
  background: #dcecff;
  border-color: #7db4f0;
}

.status-dot.paused,
.apartment-tile.paused {
  background: var(--soft-warn);
  border-color: #f0cf94;
}

.status-dot.issue,
.apartment-tile.issue {
  background: var(--soft-bad);
  border-color: #efb7b1;
}

.status-dot.not-done,
.apartment-tile.not-done {
  background: #eef1f4;
  border-color: #b7c0ca;
}

.status-dot.pending,
.apartment-tile.pending {
  background: #fdeaea;
  border-color: #efb7b1;
}

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

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

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

.task-card {
  padding: 14px;
}

.task-card.active {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 2px rgba(29, 107, 122, 0.13), var(--shadow);
}

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

.apt {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.apt strong {
  font-size: 22px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge.pending {
  background: #e9eef3;
  color: #445164;
}

.badge.progress {
  background: #e1f2f4;
  color: var(--brand-2);
}

.badge.paused {
  background: var(--soft-warn);
  color: var(--warn);
}

.badge.done {
  background: var(--soft-ok);
  color: var(--ok);
}

.badge.review {
  background: var(--soft-bad);
  color: var(--bad);
}

.task-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.meta {
  background: #f6f8fa;
  border: 1px solid #e8edf2;
  border-radius: 8px;
  padding: 8px;
  min-height: 56px;
}

.meta span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.meta strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.note-box {
  border-left: 3px solid var(--brand-2);
  padding: 8px 10px;
  background: #eef7f8;
  border-radius: 0 8px 8px 0;
  margin: 8px 0 10px;
}

.task-actions {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.task-actions button,
.actions button {
  width: 100%;
}

.photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.photo {
  min-width: 84px;
  min-height: 48px;
  display: grid;
  place-items: center;
  background: #f2f5f7;
  border: 1px dashed #aab6c2;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  padding: 6px;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
}

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

.compact-table th {
  color: var(--muted);
  font-size: 12px;
}

.review-card {
  background: #fff8f7;
  border: 1px solid #f0c4bf;
  border-radius: 8px;
  padding: 12px;
}

.history-panel {
  margin-top: 16px;
}

.empty-state {
  margin: 0;
  color: var(--muted);
}

.history-day {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 10px;
  background: #fbfcfd;
}

.history-day summary {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.history-day summary span,
.history-summary {
  color: var(--muted);
  font-size: 13px;
}

.history-summary {
  margin: 10px 0;
}

.history-table {
  min-width: 760px;
}

.history-day[open] {
  overflow-x: auto;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 25, 35, 0.44);
  z-index: 10;
}

.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: white;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.25);
}

.user-manager {
  display: grid;
  gap: 14px;
}

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

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

.user-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.user-form-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.user-form-head span {
  color: var(--muted);
  font-size: 13px;
}

.user-create-title {
  margin: 4px 0 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  font-weight: 700;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.modal h2 {
  margin: 0 0 14px;
}

.notice-backdrop {
  z-index: 20;
}

.notice-modal {
  width: min(480px, 100%);
}

.notice-body {
  margin: 0 0 16px;
  color: var(--text);
  font-size: 17px;
  line-height: 1.45;
}

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

.sync {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.sync-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
}

.hidden-file {
  display: none;
}

.cart-summary {
  display: grid;
  gap: 14px;
}

.cart-summary-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 0;
}

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

  .session {
    width: 100%;
    justify-content: space-between;
    text-align: left;
  }

  .toolbar,
  .filters,
  .admin-grid,
  .reception-grid,
  .task-meta {
    grid-template-columns: 1fr;
  }

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

  .workload-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workload-grid .metric {
    min-height: 76px;
    padding: 12px;
  }

  .workload-grid .metric span {
    font-size: 11px;
    min-height: 30px;
  }

  .workload-grid .metric strong {
    font-size: 22px;
  }

  .maid-filter,
  .reception-filter {
    max-width: none;
  }

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

  .toolbar-actions button {
    flex: 1 1 160px;
  }

  .page {
    padding: 14px;
  }

  .task-actions {
    grid-template-columns: 1fr;
  }
}
