:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #6b7788;
  --line: #dce4ee;
  --soft: #f8fafc;
  --accent: #f97316;
  --accent-dark: #d85f0f;
  --green: #159260;
  --blue: #2563a9;
  --red: #d12c2c;
  --shadow: 0 18px 42px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

.auth-page {
  align-items: flex-start;
  display: flex;
  justify-content: center;
  padding: 16px;
}

.auth-shell {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  width: min(480px, 100%);
}

.auth-brand {
  align-self: center;
}

.auth-brand h1,
.topbar h1,
.panel h2,
.section-title h3,
.form-title h2 {
  letter-spacing: 0;
  margin: 0;
}

.auth-brand h1 {
  font-size: clamp(2rem, 12vw, 3rem);
  line-height: 1;
}

.auth-copy {
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
  margin: 12px 0 0;
  max-width: 36ch;
}

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

.auth-panel {
  padding: 20px;
}

.auth-tabs {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 20px;
  padding: 4px;
}

.tab-button {
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
  min-height: 40px;
}

.tab-button.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 6px 16px rgba(31, 41, 55, 0.08);
}

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

.auth-form.is-hidden,
.is-hidden {
  display: none !important;
}

.form-title {
  margin-bottom: 4px;
}

.form-title p,
.form-message {
  color: var(--muted);
  line-height: 1.5;
  margin: 6px 0 0;
}

.form-message.is-error {
  color: var(--red);
  font-weight: 800;
}

.form-message.is-success {
  color: var(--green);
  font-weight: 800;
}

.eyebrow {
  color: #97a4b6;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.app-shell {
  margin: 0 auto;
  padding: 14px 10px 28px;
  width: 100%;
}

.topbar {
  align-items: stretch;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  flex-direction: column;
  margin-bottom: 18px;
}

.topbar h1 {
  font-size: 1.75rem;
  line-height: 1;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: stretch;
}

.topbar-actions > * {
  flex: 1 1 auto;
}

.user-chip {
  background: #edf4ff;
  border: 1px solid #cfe0f7;
  border-radius: 999px;
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 900;
  padding: 9px 12px;
}

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

.summary-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
  min-height: 92px;
  padding: 14px;
}

.summary-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.summary-card strong {
  font-size: 1.55rem;
  line-height: 1;
}

.dashboard-grid {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.panel {
  padding: 14px;
}

.panel-header,
.section-title {
  align-items: stretch;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  flex-direction: column;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 1.08rem;
  line-height: 1.2;
}

.section-title {
  border-top: 1px solid var(--line);
  margin: 18px 0 12px;
  padding-top: 16px;
}

.section-title h3 {
  font-size: 0.96rem;
}

.section-title span {
  background: #edf4ff;
  border-radius: 999px;
  color: var(--blue);
  font-size: 0.8rem;
  font-weight: 900;
  min-width: 28px;
  padding: 5px 8px;
  text-align: center;
}

.filter-grid,
.form-grid,
.log-form {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}

.filter-grid {
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: #748196;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

input,
select,
textarea {
  background: #fbfdff;
  border: 1px solid #d6e0eb;
  border-radius: 7px;
  color: var(--ink);
  min-height: 42px;
  outline: none;
  padding: 9px 11px;
  width: 100%;
}

textarea {
  line-height: 1.45;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.14);
}

input[readonly] {
  background: #f7f9fc;
  color: var(--muted);
  cursor: default;
}

.password-field {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.password-field input {
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
}

.password-toggle {
  background: #ffffff;
  border: 1px solid #d6e0eb;
  border-left: 0;
  border-radius: 0 7px 7px 0;
  color: var(--blue);
  font-weight: 900;
  min-height: 42px;
  padding: 0 12px;
}

.password-field:focus-within .password-toggle {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.14);
}

.wide-field {
  grid-column: auto;
}

.generated-box {
  align-items: center;
  background: #fff7ed;
  border: 1px dashed #fdba74;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 12px;
}

.generated-content {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.generated-box span {
  color: #a1540c;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.generated-box strong {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.copy-button {
  background: #ffffff;
  border: 1px solid #fdba74;
  border-radius: 7px;
  color: #a1540c;
  flex: 0 0 auto;
  font-weight: 900;
  min-height: 36px;
  padding: 0 12px;
}

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

.inline-section {
  margin-top: 2px;
}

.form-actions {
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: stretch;
  margin-top: 16px;
  padding-top: 14px;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  white-space: nowrap;
  width: 100%;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

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

.secondary-button {
  background: #eef7f2;
  border-color: #bfe4d1;
  color: var(--green);
}

.ghost-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.danger-button {
  background: #fff5f5;
  border-color: #f1c4c4;
  color: var(--red);
}

.table-wrap {
  border: 0;
  border-radius: 0;
  overflow: visible;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 0;
  width: 100%;
}

table,
thead,
tbody,
tr,
td {
  display: block;
}

thead {
  display: none;
}

tbody {
  display: grid;
  gap: 10px;
}

th,
td {
  border-bottom: 0;
  padding: 0;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f7f9fc;
  color: #748196;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

tbody tr {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  gap: 9px;
  padding: 12px;
}

tbody tr:hover,
tbody tr.is-selected {
  background: #fff7ed;
}

td {
  color: #344054;
  display: grid;
  font-size: 0.88rem;
  gap: 10px;
  grid-template-columns: minmax(82px, 0.38fr) minmax(0, 1fr);
}

td::before {
  color: #748196;
  content: attr(data-label);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.35;
  text-transform: uppercase;
}

td small {
  display: block;
  margin-top: 3px;
}

.resi-code {
  color: var(--ink);
  display: block;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.status-pill {
  background: #edf4ff;
  border-radius: 999px;
  color: var(--blue);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 900;
  padding: 5px 8px;
}

.status-pill.is-done {
  background: #eef7f2;
  color: var(--green);
}

.status-pill.is-cancelled {
  background: #fff5f5;
  color: var(--red);
}

.empty-state {
  color: var(--muted);
  font-weight: 800;
  margin: 12px 0 0;
}

.log-panel {
  margin-top: 2px;
}

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

.log-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.log-item {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 10px;
}

.log-item strong,
.log-item span,
.log-item p {
  overflow-wrap: anywhere;
}

.log-item strong {
  display: block;
  font-size: 0.9rem;
}

.log-item span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  margin-top: 3px;
}

.log-item p {
  margin: 0;
}

.small-danger {
  align-self: start;
  background: #fff5f5;
  border: 1px solid #f1c4c4;
  border-radius: 6px;
  color: var(--red);
  font-weight: 900;
  min-height: 32px;
  min-width: 34px;
}

.modal {
  align-items: flex-start;
  background: rgba(31, 41, 55, 0.48);
  display: flex;
  inset: 0;
  justify-content: center;
  overflow: auto;
  padding: 16px 10px;
  position: fixed;
  z-index: 30;
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  width: min(460px, 100%);
}

.account-form {
  display: grid;
  gap: 12px;
}

.toast {
  background: var(--ink);
  border-radius: 8px;
  bottom: 18px;
  color: #ffffff;
  font-weight: 900;
  left: 50%;
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  text-align: center;
  transform: translate(-50%, 14px);
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 20;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 720px) {
  .app-shell {
    padding: 20px 16px 34px;
  }

  .modal {
    align-items: center;
    padding: 24px;
  }

  .modal-panel {
    padding: 18px;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
  }

  .topbar h1 {
    font-size: 2.1rem;
  }

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

  .topbar-actions > * {
    flex: 0 0 auto;
  }

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

  .panel-header,
  .section-title {
    align-items: center;
    flex-direction: row;
  }

  .filter-grid {
    grid-template-columns: 1.3fr 1fr 1fr;
  }

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

  .wide-field {
    grid-column: 1 / -1;
  }

  .form-actions {
    flex-direction: row;
    justify-content: flex-end;
  }

  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button {
    width: auto;
  }

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

  .log-form button {
    grid-column: 1 / -1;
  }
}

@media (min-width: 860px) {
  .table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
  }

  table {
    border-collapse: collapse;
    display: table;
    min-width: 820px;
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tr {
    display: table-row;
  }

  th,
  td {
    border-bottom: 1px solid var(--line);
    display: table-cell;
    padding: 12px 10px;
  }

  td {
    gap: 0;
    grid-template-columns: none;
  }

  td::before {
    display: none;
  }

  tbody tr {
    background: transparent;
    border: 0;
    border-radius: 0;
    display: table-row;
    padding: 0;
  }
}

@media (min-width: 960px) {
  .auth-page {
    align-items: center;
    padding: 24px;
  }

  .auth-shell {
    gap: 24px;
    grid-template-columns: minmax(280px, 420px) minmax(320px, 460px);
    width: min(960px, 100%);
  }

  .auth-brand h1 {
    font-size: 4rem;
    line-height: 0.95;
  }

  .auth-copy {
    font-size: 1.04rem;
    margin-top: 18px;
  }
}

@media (min-width: 1100px) {
  .app-shell {
    width: min(1480px, 100%);
  }

  .dashboard-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(390px, 0.75fr);
  }

  .panel {
    padding: 16px;
  }

  .log-form {
    grid-template-columns: 0.75fr 1fr 1.25fr auto;
  }

  .log-form button {
    grid-column: auto;
  }
}
