:root {
  color-scheme: dark;
  --bg: #07111f;
  --bg-soft: #0b1727;
  --panel: #101d30;
  --panel-2: #14243a;
  --line: #263a55;
  --text: #edf4fb;
  --muted: #9db0c5;
  --primary: #55dfa2;
  --primary-dark: #073d2a;
  --warning: #ffc857;
  --danger: #ff8585;
  --info: #7dc4ff;
  --radius: 17px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); scroll-behavior: smooth; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 8% -10%, rgba(50, 125, 190, .28), transparent 34rem),
    radial-gradient(circle at 95% 20%, rgba(44, 193, 132, .11), transparent 28rem),
    var(--bg);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--info); }
button, input, select, textarea { font: inherit; }

.topbar {
  min-height: 78px;
  padding: 14px clamp(18px, 4vw, 54px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid rgba(80, 110, 145, .25);
  background: rgba(7, 17, 31, .82);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand span:last-child { display: grid; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .03em; }
.brand-mark {
  width: 43px;
  height: 43px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  color: #042819;
  background: linear-gradient(135deg, #70f1b6, #34b980);
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(49, 199, 137, .2);
}

.topnav { display: flex; align-items: center; justify-content: flex-end; gap: 15px; flex-wrap: wrap; }
.topnav a, .link-button { color: var(--muted); text-decoration: none; font-weight: 650; }
.topnav a:hover, .link-button:hover { color: var(--text); }
.inline-form { display: inline; margin: 0; }
.link-button { padding: 0; border: 0; background: none; cursor: pointer; }
.user-chip { color: var(--text); border: 1px solid var(--line); padding: 7px 10px; border-radius: 999px; font-size: 12px; }

.page-wrap { width: min(1120px, calc(100% - 34px)); margin: 0 auto; padding: 42px 0 70px; }
.narrow { max-width: 590px; margin-inline: auto; }
.hero { max-width: 780px; padding: clamp(28px, 6vw, 64px) 0; }
.eyebrow { color: var(--primary); font-size: 12px; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(34px, 6vw, 58px); line-height: 1.04; letter-spacing: -.045em; margin-bottom: 18px; }
h2 { font-size: 23px; letter-spacing: -.02em; }
h3 { font-size: 17px; }
.page-title { font-size: 38px; }
.lead { color: var(--muted); font-size: clamp(17px, 2vw, 20px); max-width: 690px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt-20 { margin-top: 20px; }

.panel {
  background: linear-gradient(160deg, rgba(20, 36, 58, .95), rgba(13, 27, 45, .95));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(20px, 4vw, 30px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}
.panel + .panel { margin-top: 20px; }
.panel-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.panel-header h2 { margin-bottom: 4px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats { margin-bottom: 22px; }
.stat { padding: 20px; border: 1px solid var(--line); background: rgba(8, 20, 35, .58); border-radius: 15px; }
.stat strong { display: block; font-size: 27px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 12px; }
.stat-link { color: var(--text); text-decoration: none; transition: border-color .15s ease, transform .15s ease; }
.stat-link:hover { border-color: #4eaa86; transform: translateY(-1px); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 14px currentColor; }
.status-open { color: var(--primary); background: rgba(43, 193, 130, .12); }
.status-closed { color: var(--warning); background: rgba(255, 200, 87, .12); }
.status-locked { color: var(--danger); background: rgba(255, 133, 133, .12); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 43px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--primary);
  color: #05271a;
  text-decoration: none;
  font-weight: 850;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.05); }
.document-jump {
  margin-top: 4px;
  min-height: 48px;
  padding-inline: 19px;
  box-shadow: 0 10px 28px rgba(49, 199, 137, .2);
}
#documentos-adjuntos { scroll-margin-top: 98px; }
.btn-secondary { background: var(--panel-2); color: var(--text); border-color: var(--line); }
.btn-warning { background: var(--warning); color: #3b2a00; }
.btn-danger { background: #6d2633; color: #ffe4e8; border-color: #9d4454; }
.btn:disabled { opacity: .48; cursor: not-allowed; }

.alert { margin-bottom: 18px; padding: 13px 15px; border-radius: 12px; border: 1px solid transparent; }
.alert-success { background: #12382b; border-color: #285f48; color: #c8ffe7; }
.alert-error { background: #421d28; border-color: #763343; color: #ffdce2; }
.alert-info { background: #102f48; border-color: #285576; color: #d8efff; }
.alert-warning { background: #403313; border-color: #6e5926; color: #ffeaba; }

.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(5, 15, 27, .72);
  color: var(--text);
  padding: 11px 13px;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #4eaa86; box-shadow: 0 0 0 3px rgba(78, 170, 134, .14); }
textarea { resize: vertical; min-height: 110px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 13px 15px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.code-large { font-size: 19px; letter-spacing: .08em; }
.code-input { font-size: 22px; letter-spacing: .12em; text-transform: uppercase; }
.code-input::placeholder { font-family: Inter, system-ui, sans-serif; font-size: 15px; letter-spacing: 0; text-transform: none; opacity: .68; }
.pre-wrap { white-space: pre-wrap; }
.document-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5, 15, 27, .38); }
.document-card + .document-card { margin-top: 12px; }
.document-card > div:first-child { min-width: 0; flex: 1; }
.attachment-title-list { display: grid; gap: 12px; margin: 0 0 20px; }
.attachment-title-row { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(240px, 1.2fr); gap: 16px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5, 15, 27, .38); }
.attachment-file { min-width: 0; }
.attachment-file strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-title-row .field { margin-bottom: 0; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.result-card { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5, 15, 27, .38); }
.result-card h3 { margin-bottom: 7px; }
.subpanel { padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5, 15, 27, .38); }
.filter-grid { display: grid; grid-template-columns: 1.3fr 1fr 1fr auto; gap: 14px; align-items: end; }
.filter-action { display: flex; align-items: end; }

.empty { padding: 30px; border: 1px dashed var(--line); border-radius: 14px; text-align: center; color: var(--muted); }
.upload-progress { margin-top: 20px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5, 15, 27, .5); }
.progress-bar { appearance: none; display: block; width: 100%; height: 12px; border: 1px solid #20344e; border-radius: 999px; background: #06101c; overflow: hidden; }
.progress-bar::-webkit-progress-bar { background: #06101c; }
.progress-bar::-webkit-progress-value { background: linear-gradient(90deg, #35bb81, #6df0b4); border-radius: 999px; }
.progress-bar::-moz-progress-bar { background: linear-gradient(90deg, #35bb81, #6df0b4); border-radius: 999px; }
.progress-copy { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.storage-summary { margin-bottom: 22px; }
.storage-progress { margin: 12px 0 6px; }
.storage-progress .progress-bar { height: 15px; }
.storage-delete {
  min-width: 250px;
  padding: 10px 12px;
  border: 1px solid #75404a;
  border-radius: 12px;
  background: rgba(72, 24, 36, .35);
}
.storage-delete summary { color: #ffd7de; cursor: pointer; font-weight: 800; }
.storage-delete form { margin-top: 12px; }
.storage-delete label { color: #ffd7de; }
.storage-delete input { margin-bottom: 10px; }
.storage-kind { display: grid; gap: 3px; }
.storage-kind strong { font-size: 14px; }
.storage-kind span { color: var(--muted); font-size: 12px; }
.hash { word-break: break-all; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #bdd1e4; }
.details { display: grid; grid-template-columns: minmax(150px, .6fr) minmax(0, 1.4fr); gap: 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.details dt, .details dd { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); background: rgba(5, 15, 27, .38); font-size: 12px; }
.details dd { font-weight: 650; }
.details dt:last-of-type, .details dd:last-of-type { border-bottom: 0; }
.footer { padding: 22px; text-align: center; color: #70869e; font-size: 12px; }

@media (max-width: 800px) {
  .topbar { position: static; align-items: flex-start; flex-direction: column; }
  .topnav { justify-content: flex-start; }
  .grid-4, .grid-3, .grid-2, .field-row, .result-grid, .filter-grid, .attachment-title-row { grid-template-columns: 1fr; }
  .details { grid-template-columns: 1fr; }
  .details dt, .details dd { border-bottom: 0; }
  .details dd { border-bottom: 1px solid var(--line); }
  .page-wrap { width: min(100% - 24px, 1120px); padding-top: 24px; }
  .document-card { align-items: flex-start; flex-direction: column; }
  #documentos-adjuntos { scroll-margin-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
