:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-2: #eaf1ff;
  --text: #101828;
  --muted: #64748b;
  --line: #d8e2f0;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #dbeafe;
  --accent: #7c3aed;
  --warning: #b45309;
  --danger: #b42318;
  --success: #14804a;
  --shadow: 0 18px 50px rgba(15, 23, 42, .08);
  --shadow-soft: 0 10px 28px rgba(37, 99, 235, .10);
  --radius: 8px;
  --font-sans: "Aptos", "Segoe UI Variable", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #141a23;
    --surface-soft: #182131;
    --surface-2: #1d2a44;
    --text: #edf4ff;
    --muted: #aab8ca;
    --line: #2a3850;
    --primary: #60a5fa;
    --primary-strong: #93c5fd;
    --primary-soft: #172f58;
    --accent: #a78bfa;
    --warning: #f59e0b;
    --danger: #fb7185;
    --success: #4ade80;
    --shadow: 0 18px 50px rgba(0, 0, 0, .34);
    --shadow-soft: 0 10px 28px rgba(96, 165, 250, .12);
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #141a23;
  --surface-soft: #182131;
  --surface-2: #1d2a44;
  --text: #edf4ff;
  --muted: #aab8ca;
  --line: #2a3850;
  --primary: #60a5fa;
  --primary-strong: #93c5fd;
  --primary-soft: #172f58;
  --accent: #a78bfa;
  --warning: #f59e0b;
  --danger: #fb7185;
  --success: #4ade80;
  --shadow: 0 18px 50px rgba(0, 0, 0, .34);
  --shadow-soft: 0 10px 28px rgba(96, 165, 250, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--primary) 10%, transparent), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.icon {
  width: 18px !important;
  height: 18px !important;
  max-width: 18px;
  max-height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
}

.nav .icon,
.button .icon,
.filters .icon,
.badge .icon {
  width: 16px !important;
  height: 16px !important;
  max-width: 16px;
  max-height: 16px;
}

.app-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: color-mix(in srgb, var(--surface) 96%, var(--primary) 4%);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 900;
  box-shadow: var(--shadow-soft);
}

.brand strong,
.brand small,
td small,
.list-item strong,
.list-item small {
  display: block;
}

.brand small,
.eyebrow,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav {
  display: grid;
  gap: 5px;
  margin-top: 28px;
}

.nav a,
.nav-label {
  border-radius: var(--radius);
}

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  color: var(--muted);
  font-weight: 600;
}

.nav a:hover,
.nav a.active {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.nav a.active {
  box-shadow: inset 3px 0 0 var(--primary);
}

.nav-label {
  margin: 16px 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .10em;
  text-transform: uppercase;
}

.page {
  min-width: 0;
}

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

.topbar h1,
.auth-card h1 {
  margin: 4px 0 0;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 700;
  line-height: 1.12;
}

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

.content {
  padding: 28px;
  display: grid;
  gap: 22px;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

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

.card,
.auth-card,
.table-wrap,
.panel,
.hero-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card,
.panel {
  padding: 18px;
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 26px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface));
}

.hero-panel h2 {
  margin: 12px 0 8px;
  font-size: clamp(25px, 4vw, 38px);
  line-height: 1.1;
}

.hero-panel p {
  max-width: 920px;
  margin: 0;
  color: var(--muted);
  line-height: 1.58;
}

.hero-values {
  display: grid;
  grid-template-columns: minmax(180px, 1fr);
  gap: 10px;
  min-width: 250px;
}

.hero-values div,
.price-stack,
.money-pair span {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.hero-values small,
.price-stack small,
.money-pair small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.hero-values strong,
.price-stack strong,
.money-pair strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.money-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 8px;
  min-width: 260px;
}

.stat-card {
  position: relative;
  display: grid;
  gap: 10px;
  min-height: 130px;
  overflow: hidden;
}

.stat-card:hover,
.list-item:hover {
  transform: translateY(-1px);
}

.stat-card strong {
  font-size: 31px;
  line-height: 1;
}

.stat-card span {
  color: var(--muted);
}

.icon-stat .stat-icon {
  position: absolute;
  right: 16px;
  top: 16px;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  color: var(--primary);
  background: var(--primary-soft);
}

.icon-stat .stat-icon .icon {
  width: 21px;
  height: 21px;
}

.compact-stat {
  min-height: 112px;
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.section-heading h2,
.panel h2 {
  margin: 0;
  font-size: 20px;
}

.section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

.button,
.icon-button,
.theme-switcher button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 600;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--primary);
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: white;
  box-shadow: var(--shadow-soft);
}

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  color: var(--danger);
}

.button.full {
  width: 100%;
}

.button:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, var(--line));
  background: color-mix(in srgb, var(--primary) 6%, var(--surface));
}

.button.primary:hover {
  background: linear-gradient(135deg, var(--primary-strong), var(--primary));
}

.button.danger:hover {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
  background: color-mix(in srgb, var(--danger) 7%, var(--surface));
}

.theme-switcher {
  display: flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.theme-switcher button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  color: var(--muted);
  background: transparent;
}

.theme-switcher button.active {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.menu-button {
  display: none;
  width: 42px;
  flex: 0 0 42px;
  padding: 9px;
}

.menu-button span {
  display: block;
  height: 2px;
  margin: 5px 0;
  background: var(--text);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
  font-weight: 600;
  transition: transform .16s ease, background .16s ease, color .16s ease;
}

.filters a.active {
  color: var(--primary-strong);
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--line));
}

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

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 900px;
  table-layout: fixed;
}

th,
td {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: var(--surface-soft);
}

tbody tr {
  min-height: 118px;
}

td small {
  margin-top: 4px;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 4%, transparent);
}

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

.table-title {
  font-size: 16px;
  line-height: 1.25;
}

.table-subtitle {
  max-width: 620px;
  color: var(--muted);
  line-height: 1.45;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.data-table td {
  height: 118px;
}

.data-table .money-pair {
  grid-template-columns: 1fr;
  min-width: 0;
  width: 100%;
}

.data-table .price-stack,
.data-table .money-pair span {
  min-height: 58px;
  padding: 10px 12px;
}

.data-table .price-stack strong,
.data-table .money-pair strong {
  font-size: 15px;
}

.data-table .cell-stack {
  display: flex;
  min-height: 80px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 8px;
}

.cell-title {
  width: 100%;
  min-height: 22px;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-subtitle {
  display: block;
  width: 100%;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.link-truncate,
.value-line {
  display: block;
  max-width: 100%;
  min-height: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-button-slot {
  display: flex;
  min-height: 42px;
  align-items: flex-start;
  gap: 8px;
}

.cell-button-slot.multi {
  flex-wrap: wrap;
}

.badge-slot {
  min-height: 28px;
}

.table-button {
  width: 126px;
  min-width: 126px;
  max-width: 126px;
  justify-content: center;
}

.action-stack {
  width: 126px;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
}

.action-stack .inline-form,
.action-stack .inline-form .button {
  width: 100%;
}

.table-wrap td > .row-actions {
  width: 126px;
  flex-direction: column;
  align-items: stretch;
  flex-wrap: nowrap;
}

.table-wrap td > .row-actions .button,
.table-wrap td > .row-actions summary.button {
  width: 126px;
  min-width: 126px;
  max-width: 126px;
}

.table-wrap td > .row-actions .inline-form,
.table-wrap td > .row-actions .inline-form .button {
  width: 100%;
}

.access-table {
  min-width: 1080px;
}

.access-table .col-platform {
  width: 33%;
}

.access-table .col-login {
  width: 25%;
}

.access-table .col-password {
  width: 17%;
}

.access-table .col-validity {
  width: 10%;
}

.access-table .col-actions {
  width: 15%;
}

.licitations-table {
  min-width: 1180px;
}

.licitations-table .col-main {
  width: 31%;
}

.licitations-table .col-status {
  width: 13%;
}

.licitations-table .col-date {
  width: 12%;
}

.licitations-table .col-money {
  width: 18%;
}

.licitations-table .col-platform {
  width: 12%;
}

.licitations-table .col-actions {
  width: 14%;
}

.contracts-table {
  min-width: 1080px;
}

.contracts-table .col-main {
  width: 30%;
}

.contracts-table .col-status {
  width: 12%;
}

.contracts-table .col-date {
  width: 14%;
}

.contracts-table .col-money {
  width: 17%;
}

.contracts-table .col-file {
  width: 12%;
}

.contracts-table .col-actions {
  width: 15%;
}

.invoices-table {
  min-width: 1220px;
}

.invoices-table .col-recipient {
  width: 22%;
}

.invoices-table .col-contract {
  width: 20%;
}

.invoices-table .col-status {
  width: 11%;
}

.invoices-table .col-date {
  width: 13%;
}

.invoices-table .col-money {
  width: 13%;
}

.invoices-table .col-send {
  width: 9%;
}

.invoices-table .col-actions {
  width: 12%;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.primary {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.badge.success {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 12%, var(--surface));
}

.badge.warning {
  color: var(--warning);
  background: color-mix(in srgb, var(--warning) 13%, var(--surface));
}

.badge.danger {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 11%, var(--surface));
}

.badge.info {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.form {
  display: grid;
  gap: 16px;
}

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

.form-grid .wide,
.form .wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 15%, transparent);
}

textarea {
  min-height: 116px;
  resize: vertical;
}

.check-row {
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

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

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

.alert {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.alert.success {
  border-color: color-mix(in srgb, var(--success) 30%, var(--line));
  color: var(--success);
}

.alert.danger {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
  color: var(--danger);
}

.alert.info {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--line));
  color: var(--primary-strong);
}

.flash-stack {
  display: grid;
  gap: 10px;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 34px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty-state.compact {
  padding: 18px;
  box-shadow: none;
}

.empty-state h1,
.empty-state p {
  margin: 0;
}

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

.list-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  transition: transform .16s ease, background .16s ease;
}

.list-item small {
  color: var(--muted);
}

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

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

.auth-card.wide {
  width: min(720px, 100%);
}

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

.debug-box {
  overflow: auto;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.folder-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

.folder-list {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.folder-list a {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface-soft);
}

.folder-list a.active {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.inline-form {
  display: inline;
}

details {
  position: relative;
}

summary.button {
  list-style: none;
}

summary.button::-webkit-details-marker {
  display: none;
}

details[open] > .panel {
  position: absolute;
  right: 0;
  z-index: 20;
  width: min(370px, 88vw);
  margin-top: 8px;
}

.secret-value {
  font-family: var(--font-mono);
  font-size: 14px;
  word-break: break-all;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(140px, .35fr) 1fr;
  gap: 12px 16px;
  margin: 16px 0 0;
}

.detail-grid dt {
  color: var(--muted);
  font-weight: 900;
}

.detail-grid dd {
  margin: 0;
}

.note-box {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.55;
}

.link {
  color: var(--primary-strong);
  font-weight: 800;
  word-break: break-all;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.file-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.file-card strong,
.file-card small {
  display: block;
}

.file-card small {
  margin-top: 4px;
  color: var(--muted);
}

.file-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  color: var(--primary);
  background: var(--primary-soft);
}

@media (max-width: 1180px) {
  .grid.cols-4,
  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(318px, calc(100vw - 48px));
    transform: translateX(-105%);
    transition: transform .2s ease;
    z-index: 30;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .menu-button {
    display: block;
  }

  .topbar {
    align-items: flex-start;
    padding: 16px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .content {
    padding: 16px;
  }

  .grid.cols-4,
  .grid.cols-3,
  .grid.cols-2,
  .form-grid,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    display: grid;
  }

  .hero-values,
  .money-pair {
    min-width: 0;
  }
}

@media (max-width: 580px) {
  .topbar {
    flex-wrap: wrap;
  }

  .theme-switcher {
    width: 100%;
  }

  .theme-switcher button {
    flex: 1;
  }

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

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