:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --red: #b91c1c;
  --red-dark: #7f1d1d;
  --green: #16a34a;
  --blue: #2563eb;
  --yellow: #ca8a04;
  --dark: #111827;
  --shadow: 0 16px 40px rgba(15, 23, 42, 0.09);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

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

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.page {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 148px;
  padding: 26px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(127, 29, 29, 0.96), rgba(185, 28, 28, 0.9));
  color: #fff;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
  letter-spacing: 0;
}

.hero p {
  margin: 10px 0 0;
  color: rgba(255, 255, 255, 0.88);
}

.hero-actions,
.tools,
.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.hero-actions,
.tools {
  justify-content: flex-end;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

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

.button-primary {
  background: #fff;
  color: var(--red-dark);
}

.button-red {
  background: var(--red);
  color: #fff;
}

.button-dark {
  background: var(--dark);
  color: #fff;
}

.button-blue {
  background: var(--blue);
  color: #fff;
}

.button-green {
  background: var(--green);
  color: #fff;
}

.button-ghost {
  background: #f9fafb;
  color: #1f2937;
  border: 1px solid var(--line);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 18px 0;
}

.metric,
.panel,
.login-card {
  background: var(--panel);
  border: 1px solid rgba(229, 231, 235, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 2.1rem;
  line-height: 1;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(280px, 0.7fr);
  gap: 16px;
}

.panel {
  padding: 18px;
}

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

h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0;
}

.field {
  width: 100%;
  min-height: 42px;
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  outline: 0;
}

.field:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.15);
}

.search {
  width: min(300px, 100%);
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: #374151;
  font-size: 0.9rem;
  font-weight: 800;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1040px;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #374151;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover {
  background: #f9fafb;
}

.client-name {
  font-weight: 900;
}

.client-phone {
  color: var(--muted);
  white-space: nowrap;
}

.list-summary {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  color: var(--muted);
  font-weight: 800;
}

.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.badge-new {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-active {
  background: #fef3c7;
  color: #a16207;
}

.badge-done {
  background: #dcfce7;
  color: #15803d;
}

.side-stack {
  display: grid;
  gap: 16px;
  align-content: start;
}

.empty {
  padding: 32px 10px;
  color: var(--muted);
  text-align: center;
}

.alert {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 800;
}

.alert.success {
  background: #dcfce7;
  color: #166534;
}

.alert.error {
  background: #fee2e2;
  color: #991b1b;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  padding: 24px;
}

.login-brand {
  margin-bottom: 20px;
}

.login-brand h1 {
  margin: 0;
  color: var(--red-dark);
  font-size: 2rem;
  letter-spacing: 0;
}

.login-brand p,
.hint {
  color: var(--muted);
}

.hint {
  margin: 10px 0 0;
  font-size: 0.9rem;
}

.import-summary {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.94rem;
}

@media (max-width: 900px) {
  .hero,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-actions,
  .tools {
    justify-content: flex-start;
    width: 100%;
  }

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

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

  .search {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 10px;
  }

  .hero,
  .panel,
  .metric,
  .login-card {
    padding: 14px;
  }

  .metrics {
    grid-template-columns: 1fr;
    gap: 10px;
  }

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

  .form-actions {
    flex-direction: column;
  }
}
