:root {
  color-scheme: dark;
  --bg: #080a0f;
  --surface: #0e1118;
  --surface-raised: #131721;
  --surface-hover: #171c27;
  --line: #222735;
  --line-strong: #2d3445;
  --text: #f2f5fb;
  --muted: #8991a3;
  --muted-strong: #aeb5c4;
  --blue: #1599f4;
  --blue-bright: #35b5ff;
  --blue-soft: rgba(21, 153, 244, 0.12);
  --green: #4bd4a0;
  --red: #ff6471;
  --amber: #f2b84b;
  --radius-lg: 16px;
  --radius-md: 11px;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
  font-family: "DM Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

select option {
  color: #f2f5fb;
  background: #131721;
}

select option:checked {
  color: #ffffff;
  background: #1b2636;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--blue-bright);
  outline-offset: 2px;
}

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

.topbar {
  height: 76px;
  padding: 0 clamp(22px, 4vw, 64px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 39px;
  height: 39px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #55baff;
  background: #111b2b;
  border: 1px solid #1d304b;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.brand-copy strong {
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.topbar-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  position: relative;
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--muted-strong);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.icon-button:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--line-strong);
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ccecff;
  background: var(--blue-soft);
  border: 1px solid rgba(21, 153, 244, 0.2);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.avatar:hover,
.avatar[aria-expanded="true"] {
  color: #e9f7ff;
  background: rgba(21, 153, 244, 0.2);
  border-color: rgba(53, 181, 255, 0.4);
}

.profile-menu {
  width: 270px;
  padding: 0;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 30;
  border: 1px solid var(--line-strong);
  overflow: hidden;
  border-radius: 13px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.settings-heading {
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--line);
}

.settings-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--blue-bright);
  border-radius: 8px;
  background: var(--blue-soft);
}

.settings-heading > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.settings-heading strong {
  font-size: 13px;
  font-weight: 600;
}

.settings-heading small {
  color: var(--muted);
  font-size: 10px;
}

.settings-section {
  padding: 13px;
}

.profile-menu-title {
  padding: 0 1px 8px;
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.date-options {
  padding: 3px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

.date-option {
  padding: 9px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: 8px;
  color: var(--muted-strong);
  font-size: 12px;
  cursor: pointer;
}

.date-option:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.date-option:has(input:checked) {
  color: var(--text);
  background: var(--surface-hover);
}

.date-option input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--blue);
}

main {
  width: min(1200px, calc(100% - clamp(32px, 8vw, 128px)));
  margin: 0 auto;
  padding: 36px 0 60px;
}

.login-screen {
  width: 100%;
  min-height: 100vh;
  padding: 32px 18px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 15%, rgba(21, 153, 244, 0.13), transparent 34%),
    var(--bg);
}

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

.login-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: #ccecff;
  border: 1px solid rgba(21, 153, 244, 0.28);
  border-radius: 13px;
  background: var(--blue-soft);
  font-size: 13px;
  font-weight: 700;
}

.login-heading h1 {
  font-size: 31px;
}

.login-heading > p:last-child {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-error {
  margin: -3px 0 0;
  color: var(--red);
  font-size: 12px;
}

.login-button,
.profile-logout {
  width: 100%;
}

.profile-logout {
  min-height: 37px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue-bright);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(30px, 4vw, 43px);
  line-height: 1.05;
}

h2 {
  font-size: 23px;
}

.heading-subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 42px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.primary-button {
  color: #fff;
  border: 1px solid #168bcf;
  background: #117fbd;
  box-shadow: none;
}

.primary-button:hover {
  border-color: #209ddd;
  background: #168dca;
}

.secondary-button {
  color: var(--muted-strong);
  border: 1px solid var(--line-strong);
  background: var(--surface-raised);
}

.secondary-button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.danger-button {
  color: var(--red);
  border: 1px solid color-mix(in srgb, var(--red) 28%, var(--line));
  background: color-mix(in srgb, var(--red) 8%, transparent);
}

.danger-button:hover {
  background: color-mix(in srgb, var(--red) 14%, transparent);
}

.status-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}

.status-tabs::-webkit-scrollbar {
  display: none;
}

.status-tab {
  min-width: max-content;
  padding: 0 14px 13px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

.status-tab:hover {
  color: var(--text);
}

.status-tab.active {
  color: var(--text);
}

.status-tab.active::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: -1px;
  left: 12px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--blue-bright);
}

.tab-count {
  min-width: 25px;
  height: 25px;
  padding: 0 7px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  color: var(--muted-strong);
  background: var(--surface-raised);
  font-size: 11px;
}

.status-tab.active .tab-count {
  color: var(--blue-bright);
  background: var(--blue-soft);
}

.toolbar {
  margin-top: 18px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 210px;
  gap: 12px;
}

.search-box,
.select-wrap {
  height: 44px;
  display: flex;
  align-items: center;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.search-box {
  gap: 10px;
  padding: 0 13px;
}

.search-box:focus-within,
.select-wrap:focus-within {
  border-color: rgba(53, 181, 255, 0.75);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.search-box input,
.select-wrap select {
  min-width: 0;
  width: 100%;
  height: 100%;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-box kbd {
  padding: 3px 6px;
  color: var(--muted);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 5px;
  font: 10px/1 "DM Sans", sans-serif;
  white-space: nowrap;
}

.select-wrap {
  padding: 0 11px 0 13px;
}

.select-wrap select {
  appearance: none;
}

.select-wrap svg {
  pointer-events: none;
}

.summary {
  margin: 12px 0;
  padding: 13px 17px;
  display: flex;
  align-items: center;
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface) 72%, transparent);
}

.summary-item {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

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

.summary-item strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.summary-profit strong {
  color: var(--green);
}

.summary-divider {
  width: 1px;
  height: 18px;
  background: var(--line-strong);
}

.case-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.08);
}

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

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

th,
td {
  padding: 0 8px;
  text-align: left;
}

th:first-child,
td:first-child {
  padding-left: 14px;
}

th:last-child,
td:last-child {
  padding-right: 10px;
}

thead {
  background: color-mix(in srgb, var(--surface-raised) 65%, transparent);
}

th {
  height: 36px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  height: 52px;
  border-bottom: 1px solid var(--line);
  color: var(--muted-strong);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

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

tbody tr {
  transition: background 130ms ease;
}

tbody tr:hover {
  background: var(--surface-hover);
}

.client-cell {
  min-width: 190px;
}

.client-info {
  display: flex;
  align-items: center;
}

.client-detail {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.client-detail strong {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-name-row {
  width: 100%;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.case-reference {
  width: 50px;
  flex: 0 0 50px;
  display: block;
  color: #66839d;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
}

.owner-badge {
  padding: 4px 7px;
  display: inline-flex;
  color: #b8dfff;
  border: 1px solid rgba(21, 153, 244, 0.18);
  border-radius: 6px;
  background: rgba(21, 153, 244, 0.08);
  font-size: 10px;
  font-weight: 600;
}

.client-email {
  max-width: 230px;
  padding-left: 58px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.amount-cell {
  color: var(--text);
  font-weight: 600;
}

.profit-cell strong {
  color: var(--green);
  font-weight: 600;
}

.profit-cell small {
  margin-left: 4px;
  color: var(--muted);
  font-size: 10px;
}

.status-badge {
  width: max-content;
  padding: 6px 9px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px currentcolor;
  opacity: 0.85;
  transform: scale(0.55);
}

.status-to-launch {
  color: #a7afc0;
  background: rgba(137, 145, 163, 0.1);
}

.status-in-progress {
  color: #4ebcff;
  background: rgba(21, 153, 244, 0.11);
}

.status-to-pay {
  color: var(--amber);
  background: rgba(242, 184, 75, 0.1);
}

.status-paid {
  color: var(--green);
  background: rgba(75, 212, 160, 0.1);
}

.status-cell {
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 6px;
}

.procedure-duration {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.edit-button {
  width: 34px;
  height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
}

.edit-button:hover {
  color: var(--blue-bright);
  border-color: rgba(21, 153, 244, 0.18);
  background: var(--blue-soft);
}

.empty-state {
  padding: 70px 20px;
  text-align: center;
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 15px;
  display: grid;
  place-items: center;
  color: var(--blue-bright);
  border-radius: 12px;
  background: var(--blue-soft);
}

.empty-state strong {
  font-size: 15px;
}

.empty-state p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.case-dialog {
  width: min(610px, calc(100% - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  overflow-y: auto;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.case-dialog::backdrop {
  background: rgba(2, 4, 8, 0.78);
}

.dialog-header {
  padding: 23px 24px 19px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.close-button {
  border-color: transparent;
}

.form-grid {
  padding: 22px 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 17px 14px;
}

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

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

.field > span {
  color: var(--muted-strong);
  font-size: 11px;
  font-weight: 600;
}

.field > span small {
  color: var(--muted);
  font-size: inherit;
  font-weight: 400;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: 0;
  background: var(--surface);
  font-size: 13px;
}

.field input,
.field select {
  height: 42px;
}

.field textarea {
  min-height: 88px;
  padding-top: 11px;
  padding-bottom: 11px;
  resize: vertical;
  line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.input-suffix {
  position: relative;
}

.input-suffix input {
  padding-right: 34px;
}

.input-suffix > span {
  position: absolute;
  top: 50%;
  right: 12px;
  color: var(--muted);
  font-size: 12px;
  transform: translateY(-50%);
}

.profit-preview {
  margin: 0 24px 22px;
  padding: 13px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(75, 212, 160, 0.17);
  border-radius: 10px;
  background: rgba(75, 212, 160, 0.06);
}

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

.profit-preview strong {
  color: var(--green);
  font-size: 15px;
}

.dialog-footer {
  padding: 17px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
}

.dialog-footer > .dialog-actions:only-child {
  margin-left: auto;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  padding: 11px 15px;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  font-size: 12px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  position: absolute;
}

@media (max-width: 800px) {
  .topbar {
    height: 68px;
    padding: 0 18px;
  }

  main {
    width: calc(100% - 28px);
    padding: 32px 0 50px;
  }

  .page-heading {
    align-items: center;
    margin-bottom: 28px;
  }

  .heading-subtitle {
    display: none;
  }

  .status-tab {
    padding-right: 11px;
    padding-left: 11px;
  }

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

  .search-box kbd {
    display: none;
  }

  .summary {
    gap: 14px;
    overflow-x: auto;
  }

  .summary-item {
    min-width: max-content;
    flex-direction: column;
    gap: 4px;
  }

  .summary-divider {
    height: 31px;
  }

  .case-panel {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .table-scroll {
    overflow: visible;
  }

  table,
  tbody {
    min-width: 0;
    display: block;
  }

  thead {
    display: none;
  }

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

  tbody tr {
    padding: 16px;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 17px 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
  }

  tbody tr:hover {
    background: var(--surface);
  }

  td,
  th:first-child,
  td:first-child,
  th:last-child,
  td:last-child {
    height: auto;
    padding: 0;
    border: 0;
  }

  td:not(.client-cell, .actions-cell) {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  td:not(.client-cell, .actions-cell)::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .client-cell {
    min-width: 0;
    padding-right: 38px !important;
    grid-column: 1 / -1;
  }

  .client-detail span {
    max-width: 230px;
  }

  .actions-cell {
    position: absolute;
    top: 16px;
    right: 14px;
  }
}

@media (max-width: 560px) {
  .page-heading .primary-button {
    width: 42px;
    padding: 0;
    overflow: hidden;
    color: transparent;
    gap: 0;
  }

  .page-heading .primary-button svg {
    position: absolute;
    color: #fff;
  }

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

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

  .dialog-footer {
    align-items: stretch;
    flex-direction: column-reverse;
    gap: 12px;
  }

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

  .danger-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
