:root {
  --bg: #070b13;
  --panel: #0d1320;
  --panel-2: #111a2b;
  --line: #1c2942;
  --ink: #e9eef8;
  --muted: #8b96ab;
  --blue: #4f8ef7;
  --blue-soft: #7fb2ff;
  --red: #e5484d;
  --green: #34c759;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 700; letter-spacing: 0.3px; }
a { color: var(--blue-soft); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.ic { vertical-align: -3px; }
.arrow { margin-left: 4px; }
.empty { color: var(--muted); font-size: 14px; padding: 12px 0; list-style: none; }
code {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
}

.kicker {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3.5px;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

/* ------------------------------------------------ buttons */

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  width: 100%;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3b74e0, #2954b8);
  border: 1px solid #4a80e8;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary:hover { background: linear-gradient(135deg, #4a83ef, #3161c9); text-decoration: none; }
.btn-primary.slim { width: auto; margin-top: 0; padding: 9px 16px; font-size: 14px; }
.btn-primary[disabled] { opacity: 0.6; cursor: wait; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-soft);
  background: rgba(79, 142, 247, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--blue); text-decoration: none; }
.btn-ghost.wide { width: 100%; margin-top: 14px; }

button.linklike {
  background: none;
  border: 0;
  width: auto;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: 13.5px;
  color: var(--blue-soft);
  cursor: pointer;
}
button.linklike:hover { background: none; text-decoration: underline; }
button.linklike.danger { color: var(--red); }

/* ------------------------------------------------ auth screens */

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(47, 107, 255, 0.12), transparent),
    var(--bg);
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 430px;
}

.auth-card .brand-mark { margin-bottom: 14px; }
.auth-card .kicker { font-size: 11px; }
.auth-wordmark { font-size: 30px; font-weight: 800; letter-spacing: 2px; margin-bottom: 26px; }
.auth-card h1 { font-size: 19px; margin-bottom: 8px; font-weight: 600; }
.auth-card .muted { margin-bottom: 8px; line-height: 1.55; font-size: 13.5px; }
.auth-card ol { margin: 10px 0 0 18px; color: var(--muted); font-size: 13.5px; line-height: 1.7; }

.auth-foot {
  margin-top: 20px;
  color: var(--muted);
  font-size: 12.5px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ------------------------------------------------ forms */

form label {
  display: block;
  margin: 16px 0 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

input[type="text"], input[type="email"], input[type="password"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
input[type="file"] { color: var(--muted); font-size: 13.5px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
::placeholder { color: #5b6780; }
select { appearance: none; }
input[type="date"] { color-scheme: dark; }

.form-panel { max-width: 460px; }
.form-panel .btn-primary { width: auto; }

.alert, .success {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.alert { background: rgba(229, 72, 77, 0.12); color: #ff8f92; border: 1px solid rgba(229, 72, 77, 0.35); }
.success { background: rgba(52, 199, 89, 0.1); color: #6fdd90; border: 1px solid rgba(52, 199, 89, 0.3); }

/* ------------------------------------------------ toast */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 14px;
  max-width: 90vw;
}
.toast.error { border-color: rgba(229, 72, 77, 0.6); color: #ff8f92; }

/* ------------------------------------------------ layout */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 218px;
  flex-shrink: 0;
  background: #0a0f1a;
  border-right: 1px solid var(--line);
  padding: 22px 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: block; padding: 0 8px; }

.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}
.nav-item:hover { color: var(--ink); background: var(--panel-2); text-decoration: none; }
.nav-item.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(63, 114, 224, 0.35), rgba(63, 114, 224, 0.1));
  border-left: 3px solid var(--blue);
  padding-left: 9px;
}

.sidebar-foot { border-top: 1px solid var(--line); padding-top: 16px; }
.build-stamp { margin-top: 10px; text-align: center; color: #3a4a63; font-size: 10.5px; letter-spacing: 0.5px; }
.side-quote { color: var(--muted); font-size: 12.5px; line-height: 1.5; text-align: center; padding: 0 6px 12px; }
.signout {
  width: 100%;
  background: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.signout:hover { color: var(--ink); border-color: var(--blue); }

.content {
  flex: 1;
  padding: 34px 38px 26px;
  max-width: 1380px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-head h1 { font-size: 26px; }
.entity-head { justify-content: flex-start; }
.entity-head .muted { margin-top: 4px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 20px;
}

.site-foot {
  text-align: center;
  padding: 18px 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.site-foot span { margin: 0 6px; }

/* ------------------------------------------------ dashboard top row */

.dash-top {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.dash-title h1 { font-size: 40px; letter-spacing: 4px; text-transform: uppercase; }
.tagline { margin-top: 6px; color: var(--muted); font-size: 15px; }
.tagline .accent { color: var(--blue-soft); }

.quote-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.quote-mark { color: var(--blue); font-size: 34px; font-family: Georgia, serif; line-height: 0.8; flex-shrink: 0; }
.quote-mark.close { align-self: flex-end; line-height: 0.2; }
.quote-card p { font-size: 15px; line-height: 1.5; padding-top: 2px; flex: 1; }

.quick-actions {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
}
.qa-row { display: flex; gap: 10px; }
.qa {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 12.5px;
  text-align: center;
}
.qa:hover { border-color: var(--blue); text-decoration: none; }
.qa .ic { color: var(--blue-soft); }

/* ------------------------------------------------ entity logos */

.logo-img {
  display: flex;
  align-items: center;
  justify-content: center;
  height: var(--lh, 72px);
  max-width: 175px;
}
.logo-img img { max-height: 100%; max-width: 100%; object-fit: contain; }
.logo-img.tile {
  background: #fff;
  border-radius: 10px;
  padding: 5px 7px;
}

/* ------------------------------------------------ entity cards */

.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.entity-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.entity-card:hover { border-color: var(--blue); }
.entity-card h2 { font-size: 14.5px; font-weight: 600; line-height: 1.35; min-height: 40px; }
.entity-card .btn-ghost { width: 100%; margin-top: auto; }

/* ------------------------------------------------ common docs + tasks */

.dash-bottom {
  display: grid;
  grid-template-columns: 2.15fr 1fr;
  gap: 20px;
  align-items: start;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}

.doc-card {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  color: var(--ink);
}
.doc-card:hover { border-color: var(--blue); text-decoration: none; }
.doc-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; line-height: 1.4; min-height: 36px; }
.doc-card .btn-ghost { width: 100%; margin-top: auto; }

.doc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1.5px solid var(--ring, var(--blue));
  color: var(--ring, var(--blue));
}
.doc-icon.sm { width: 34px; height: 34px; margin-right: 10px; }

/* ------------------------------------------------ tasks */

.task-list { list-style: none; padding: 0; }

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.task-row:first-child { border-top: 0; }
.task-row form { margin: 0; }
.task-row.done .task-title { text-decoration: line-through; color: var(--muted); }

.task-check {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--muted);
  border-radius: 5px;
  background: none;
  color: var(--green);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.task-check:hover { border-color: var(--blue); }
.task-check.checked { border-color: var(--green); }

.task-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.task-title { font-size: 14px; }
.task-due { color: var(--blue-soft); font-size: 13px; white-space: nowrap; }

.task-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.task-form input[type="text"] { flex: 2; min-width: 200px; width: auto; }
.task-form select, .task-form input[type="date"] { flex: 1; min-width: 140px; width: auto; }

/* ------------------------------------------------ document sections */

.doc-section { padding: 18px 22px; position: relative; }

.doc-section.drag-over { border-color: var(--blue); }
.doc-section.drag-over::after {
  content: 'Drop to upload here';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 19, 32, 0.88);
  border: 1.5px dashed var(--blue);
  border-radius: 12px;
  color: var(--blue-soft);
  font-weight: 600;
  letter-spacing: 0.5px;
  pointer-events: none;
}

.doc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.doc-head h2 { font-size: 15.5px; font-weight: 600; display: flex; align-items: center; }
.doc-head form { margin: 0; }

.upload-btn input { display: none; }

.file-list { list-style: none; padding: 0; margin-top: 12px; }

.file-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.file-row:first-child { border-top: 0; }
.file-row form { margin: 0; display: inline; }

.file-name { flex: 1; word-break: break-word; font-size: 14px; }
button.file-name {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
button.file-name:hover { color: var(--blue-soft); text-decoration: underline; }

.update-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 18px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #3b74e0, #2954b8);
  border: 1px solid #4a80e8;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
}

/* ------------------------------------------------ file preview lightbox */

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(4, 7, 13, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.preview-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  width: min(960px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.preview-title { font-weight: 600; font-size: 14px; word-break: break-all; }
.preview-actions { display: flex; gap: 16px; align-items: center; flex-shrink: 0; }
.preview-close {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.preview-close:hover { color: var(--ink); }
.preview-body {
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  min-height: 180px;
}
.preview-media { max-width: 100%; max-height: calc(92vh - 96px); border-radius: 6px; }
img.preview-media { background: #fff; padding: 10px; }
.preview-frame { width: 100%; height: calc(92vh - 96px); border: 0; border-radius: 6px; background: #fff; }
.preview-pdfwrap {
  width: 100%;
  max-height: calc(92vh - 96px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 4px;
}
.pdf-page { max-width: 100%; border-radius: 4px; box-shadow: 0 2px 14px rgba(0,0,0,0.5); background: #fff; }
.pdf-status { padding: 30px 0; }
.preview-text {
  width: 100%;
  max-height: calc(92vh - 96px);
  overflow: auto;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.preview-none {
  text-align: center;
  color: var(--muted);
  padding: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  line-height: 1.6;
}

@media (max-width: 760px) {
  .preview-overlay { padding: 8px; }
  .preview-box { max-height: 96vh; }
  .preview-media { max-height: calc(96vh - 92px); }
  .preview-frame { height: calc(96vh - 92px); }
}
.file-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.file-actions { display: flex; gap: 14px; align-items: center; font-size: 13.5px; }

.chip.personal { --chip: #8b96ab; }
.chip {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--chip, var(--blue));
  border: 1px solid var(--chip, var(--blue));
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
}

/* ------------------------------------------------ entity form swatches */

.swatch-row { display: flex; gap: 10px; margin-top: 4px; }
.swatch input { display: none; }
.swatch span {
  display: block;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sw);
  border: 2px solid transparent;
  cursor: pointer;
}
.swatch input:checked + span { border-color: #fff; }

/* ------------------------------------------------ wallet */

.warn-note {
  margin: 12px 0 4px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  line-height: 1.5;
  color: #f2c14e;
  background: rgba(212, 161, 42, 0.1);
  border: 1px solid rgba(212, 161, 42, 0.35);
}
.check-row {
  display: flex !important;
  gap: 10px;
  align-items: flex-start;
  font-weight: 400 !important;
  font-size: 13.5px !important;
  line-height: 1.5;
  color: var(--muted);
}
.check-row input { margin-top: 3px; }

.wallet-add { flex-wrap: wrap; }
.wallet-add .qa { flex: 1 1 140px; font: inherit; font-size: 12.5px; cursor: pointer; }
.wallet-form { margin-top: -6px; }
.wallet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
}
.wfilter { width: auto; padding: 7px 32px 7px 12px; font-size: 13.5px; }

.wallet-item { padding: 16px 22px 12px; }
.wallet-item .doc-head h2 { flex-wrap: wrap; gap: 6px; }
.whint { color: var(--muted); font-weight: 400; font-size: 13.5px; margin-left: 8px; letter-spacing: 1px; }
.wactions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: flex-end; }

.wrows { margin-top: 10px; }
.wrow {
  display: grid;
  grid-template-columns: 170px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.wrow:first-child { border-top: 0; }
.wrow-label { color: var(--muted); font-size: 12.5px; }
.wrow-value {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  letter-spacing: 0.5px;
  word-break: break-all;
}
.wrow-value.masked { color: var(--muted); letter-spacing: 2px; }
.wcopy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blue-soft);
  background: rgba(79, 142, 247, 0.08);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.wcopy:hover { border-color: var(--blue); }

@media (max-width: 760px) {
  .wrow { grid-template-columns: 1fr auto; }
  .wrow-label { grid-column: 1 / -1; padding-bottom: 0; }
}

/* ------------------------------------------------ backup */

.backup-note { margin-bottom: 16px; line-height: 1.55; }

/* ------------------------------------------------ entity description */

.desc-text { margin-top: 4px; line-height: 1.6; white-space: pre-wrap; }
.desc-panel textarea { margin-top: 4px; }
.desc-actions { display: flex; gap: 10px; margin-top: 12px; }
.desc-actions .btn-primary { margin-top: 0; }

/* ------------------------------------------------ notes */

.note-card .note-body { margin: 10px 0; line-height: 1.55; color: var(--ink); white-space: pre-wrap; }

/* ------------------------------------------------ small screens */

@media (max-width: 1100px) {
  .dash-top { grid-template-columns: 1fr 1fr; }
  .dash-title { grid-column: 1 / -1; }
  .dash-bottom { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .content { padding: 24px 18px 40px; }
  .dash-top { grid-template-columns: 1fr; }
  .file-row { flex-wrap: wrap; }
}
