:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #dbe2ef;
  --primary: #3559e0;
  --primary-dark: #2747c7;
  --secondary-bg: #eef2ff;
  --danger: #b9382f;
  --radius: 18px;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, Arial, sans-serif;
  background: linear-gradient(180deg, #eef3ff 0%, var(--bg) 100%);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.screen {
  min-height: 100vh;
}

.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card,
.panel,
.modal {
  background: var(--card);
  border: 1px solid rgba(219, 226, 239, 0.75);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.auth-card h1,
.topbar h1,
.panel h2,
.modal h2,
.settings-section h3 {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
  margin-top: 12px;
}

.stack,
.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-weight: 600;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(53, 89, 224, 0.18);
  border-color: rgba(53, 89, 224, 0.6);
}

.primary,
.secondary,
.icon-btn,
.stat-card {
  border: none;
  border-radius: 12px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
}

.primary {
  background: var(--primary);
  color: #fff;
  padding: 12px 18px;
  box-shadow: 0 12px 24px rgba(53, 89, 224, 0.2);
}

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

.secondary {
  background: var(--secondary-bg);
  color: var(--text);
  padding: 12px 18px;
}

.small {
  padding: 10px 14px;
}

.primary:hover,
.secondary:hover,
.icon-btn:hover,
.stat-card:hover {
  transform: translateY(-1px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 32px 12px;
  gap: 16px;
  background: rgba(245, 247, 251, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(219, 226, 239, 0.8);
}

.topbar-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.layout {
  padding: 0 32px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  padding: 20px;
}

.sticky-panel {
  position: sticky;
  top: 88px;
  z-index: 30;
}


.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(140px, 0.7fr)) auto;
  gap: 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.grow {
  min-width: 0;
}

.search-inline {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 10px;
}

.toolbar-buttons,
.quick-buttons,
.modal-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.quick-buttons {
  margin-top: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  text-align: left;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.stat-card .stat-label {
  display: block;
  color: var(--muted);
  margin-bottom: 10px;
}

.stat-card strong {
  font-size: 28px;
  color: var(--text);
}

.stat-card.active {
  border-color: rgba(53, 89, 224, 0.55);
  box-shadow: 0 16px 40px rgba(53, 89, 224, 0.16);
  background: #f5f8ff;
}

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

.panel-head.tight {
  align-items: flex-start;
}

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

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

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

th {
  color: var(--muted);
  font-size: 14px;
  background: #fff;
}

tbody tr:hover {
  background: rgba(53, 89, 224, 0.04);
}

.row-saving {
  opacity: 0.72;
}

.status-pill,
.named-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill {
  background: #eef3ff;
  color: #2747c7;
}

.status-pill.waiting {
  background: #fff6da;
  color: #9a6b00;
}

.status-pill.closed {
  background: #e8f7ee;
  color: #1f7a47;
}

.status-pill.refused {
  background: #fdecea;
  color: #b9382f;
}

.inline-control {
  width: 100%;
  min-width: 140px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
}

.inline-date {
  min-width: 150px;
}

.inline-text {
  min-width: 220px;
}

.inline-select {
  min-width: 150px;
}

.inline-select-colored {
  font-weight: 700;
  border-color: transparent;
}

.inline-display {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  color: var(--text);
}

.row-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.save-hint {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}


.row-actions-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

table-action-btn {
  white-space: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  width: min(100%, 980px);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
}

.settings-modal {
  width: min(100%, 1180px);
}

.icon-btn {
  width: 40px;
  height: 40px;
  background: #eef2ff;
  color: var(--text);
}

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

.full {
  grid-column: 1 / -1;
}

.settings-form {
  gap: 20px;
}

.settings-section {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: #fbfcff;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(220px, 280px) minmax(140px, 220px) auto;
  gap: 12px;
  align-items: center;
}

.color-field-inline {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
}

.settings-preview {
  display: flex;
  justify-content: flex-start;
}

.settings-pill-preview {
  min-width: 110px;
}

input[type="color"] {
  min-height: 46px;
  padding: 6px;
}

.danger-ghost {
  background: #fff1f0;
  color: #b9382f;
}

@media (max-width: 980px) {
  .topbar,
  .layout {
    padding-left: 18px;
    padding-right: 18px;
  }

  .toolbar,
  .settings-row,
  .search-inline,
  .grid.two,
  .color-field-inline {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 18px;
  }
}


@media (max-width: 900px) {
  .topbar {
    position: static;
  }

  .sticky-panel {
    position: static;
  }

  th {
    position: static;
  }
}
