:root {
  --ink: #242842;
  --muted: #66758a;
  --line: #d6e0e8;
  --bg: #f1f5f8;
  --brand: #303462;
  --brand-dark: #242747;
  --accent: #5482a3;
  --soft: #edf4f8;
  --danger: #b42318;
  --radius: 14px;
  font-family: "Segoe UI", Aptos, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 16px;
}

.account {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: right;
}

.account span {
  display: inline;
  font-weight: 600;
}

.account .link-button {
  text-decoration: none;
  white-space: nowrap;
}

.settings-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 30px 28px 60px;
}

.settings-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.settings-heading h1 {
  margin: 5px 0 7px;
  font-size: 28px;
}

.settings-heading p,
.settings-card-title p,
.logo-card > p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.settings-notice {
  margin-bottom: 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

.settings-card {
  padding: 22px;
}

.settings-card-title h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.settings-card-title.separated {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  margin-top: 24px;
}

.settings-card label {
  position: relative;
}

.settings-card label small {
  position: absolute;
  right: 11px;
  bottom: 12px;
  color: var(--muted);
  font-weight: 500;
}

.settings-card label:has(small) input {
  padding-right: 55px;
}

.logo-card {
  grid-column: 1 / -1;
}

.logo-card img {
  display: block;
  width: 170px;
  height: 170px;
  object-fit: contain;
  margin: 20px 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
}

.settings-card input {
  text-transform: none;
}

@media (max-width: 760px) {
  .account {
    gap: 8px;
  }
  .account span {
    display: none;
  }
  .settings-shell {
    padding: 20px 12px 40px;
  }
  .settings-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .settings-heading .button {
    width: 100%;
  }
  .settings-grid {
    grid-template-columns: 1fr;
  }
  .logo-card {
    grid-column: auto;
  }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
.hidden {
  display: none !important;
}
.topbar {
  height: 86px;
  background: white;
  border-bottom: 3px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo {
  width: 60px;
  height: 60px;
  object-fit: contain;
  flex: 0 0 auto;
}
.brand strong {
  display: block;
  font-size: 18px;
  color: var(--brand);
}
.brand span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.account {
  text-align: right;
  font-size: 14px;
}
.account span {
  display: block;
  font-weight: 600;
}
.link-button {
  border: 0;
  background: none;
  color: var(--brand);
  padding: 3px 0;
}
.layout {
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px 28px;
  display: grid;
  grid-template-columns: 370px minmax(0, 1fr);
  gap: 20px;
}
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}
.sidebar {
  align-self: start;
  position: sticky;
  top: 98px;
}
.sidebar-tools {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.button-row,
.actions,
.compact-actions {
  display: flex;
  gap: 8px;
}
.grow {
  flex: 1;
}
.button {
  min-height: 40px;
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-weight: 650;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.button.primary {
  background: var(--brand);
  color: white;
}
.button.primary:hover {
  background: var(--brand-dark);
}
.button.secondary {
  background: white;
  border-color: #cbd5e1;
  color: #334155;
}
.button.secondary:hover {
  background: #f8fafc;
}
.button.small {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}
.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.search {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-top: 12px;
}
.search span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.search input {
  width: 100%;
  margin-top: 0;
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f1f5f9;
  border-radius: 9px;
  padding: 3px;
  margin-top: 12px;
}
.tab {
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 8px;
  color: var(--muted);
  font-weight: 650;
  font-size: 14px;
}
.tab.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  padding: 9px 11px;
  outline: none;
  min-height: 40px;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(84, 130, 163, 0.2);
}
input:disabled,
select:disabled,
textarea:disabled {
  background: #f1f5f9;
  color: #64748b;
}
.document-list {
  max-height: calc(100vh - 260px);
  min-height: 300px;
  overflow: auto;
  padding: 8px;
}
.doc-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 11px;
  background: white;
  text-align: left;
  padding: 12px;
  margin-bottom: 3px;
}
.doc-item:hover {
  background: #f8fafc;
  border-color: var(--line);
}
.doc-item.selected {
  background: var(--soft);
  border-color: var(--accent);
}
.doc-top,
.doc-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.doc-top strong {
  font-size: 14px;
}
.doc-item > span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 14px;
  margin: 6px 0;
  color: #334155;
}
.doc-bottom {
  font-size: 12px;
  color: var(--muted);
}
.status {
  font-size: 11px;
  border-radius: 99px;
  padding: 3px 7px;
  background: #fef3c7;
  color: #92400e;
}
.status.final {
  background: #d1fae5;
  color: #065f46;
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 70px 20px;
  font-size: 14px;
}
.workspace-header {
  min-height: 88px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 26px;
}
.workspace-header h1 {
  font-size: 22px;
  margin: 3px 0 0;
}
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-weight: 800;
}
.workspace-body {
  padding: 24px 26px;
}
.notice {
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 18px;
  font-size: 14px;
}
.top-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 18px;
}
.panel h2 {
  font-size: 16px;
  margin: 0;
}
.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.linked {
  font-size: 12px;
  color: #047857;
  margin-top: 4px;
  display: block;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  margin-top: 16px;
}
.form-grid .full {
  grid-column: 1/-1;
}
label {
  display: block;
  color: #475569;
  font-size: 13px;
  font-weight: 650;
}
label input,
label select,
label textarea {
  margin-top: 6px;
}
.summary dl {
  margin: 17px 0;
}
.summary dl div {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 12px;
  font-size: 14px;
}
.summary dd {
  margin: 0;
  font-weight: 700;
}
.summary .muted {
  color: var(--muted);
}
.summary .grand {
  border-top: 1px solid var(--line);
  padding-top: 13px;
  font-size: 18px;
}
.summary .grand dd {
  color: var(--accent);
}
.summary p {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  padding: 11px;
  border-radius: 8px;
}
.lines-panel {
  margin-top: 18px;
  padding: 0;
}
.lines-panel .panel-title-row {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.table-scroll {
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  font-size: 14px;
}
th {
  text-align: left;
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px;
}
td {
  border-top: 1px solid #edf2f7;
  padding: 9px;
}
th:nth-child(2),
td:nth-child(2) {
  width: 90px;
}
th:nth-child(3),
td:nth-child(3) {
  width: 135px;
}
th:nth-child(4),
td:nth-child(4) {
  width: 90px;
}
th:nth-child(5),
td:nth-child(5) {
  width: 120px;
}
th:last-child,
td:last-child {
  width: 44px;
}
.right {
  text-align: right;
}
.line-total {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}
.remove-line {
  border: 0;
  background: none;
  color: #94a3b8;
  font-size: 20px;
}
.remove-line:hover {
  color: var(--danger);
}
.notes-label {
  margin-top: 18px;
}
.notes-label textarea {
  resize: vertical;
}
.dialog {
  border: 0;
  border-radius: 16px;
  padding: 22px;
  width: min(520px, calc(100vw - 28px));
  box-shadow: 0 25px 75px rgba(15, 23, 42, 0.26);
}
.dialog.wide {
  width: min(700px, calc(100vw - 28px));
}
.dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}
.dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}
.dialog-header h2 {
  margin: 0;
  font-size: 21px;
}
.dialog-header p {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 14px;
}
.dialog-close {
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--muted);
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}
.dialog-form {
  max-height: 58vh;
  overflow: auto;
  padding: 1px 4px 8px;
}
.customer-list {
  border: 1px solid var(--line);
  border-radius: 11px;
  margin-top: 12px;
  max-height: 52vh;
  min-height: 220px;
  overflow: auto;
  padding: 6px;
}
.customer-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border-radius: 9px;
}
.customer-row:hover {
  background: #f8fafc;
}
.customer-main {
  border: 0;
  background: none;
  text-align: left;
  min-width: 0;
  flex: 1;
  padding: 2px;
}
.customer-main strong,
.customer-main span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.customer-main strong {
  font-size: 14px;
}
.customer-main span {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}
.edit-customer {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
}
.radio-card {
  display: flex;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 14px;
  margin-top: 12px;
}
.radio-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--soft);
}
.radio-card input {
  width: auto;
  min-height: 0;
  margin: 3px 0;
}
.radio-card strong,
.radio-card small {
  display: block;
}
.radio-card small {
  color: var(--muted);
  margin-top: 3px;
}
.toast {
  position: fixed;
  right: 22px;
  top: 92px;
  z-index: 30;
  background: #0f172a;
  color: white;
  border-radius: 9px;
  padding: 11px 15px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.25);
  font-size: 14px;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: 0.2s;
}
.toast.show {
  opacity: 1;
  transform: none;
}
.toast.error {
  background: #991b1b;
}
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(145deg, #e5edf3, #f8fafc 55%);
}
.login-card {
  width: min(420px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 24px 65px rgba(15, 23, 42, 0.12);
}
.login-brand {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.login-card h1 {
  font-size: 24px;
  margin: 25px 0 18px;
}
.login-card form {
  display: grid;
  gap: 15px;
}
.login-button {
  width: 100%;
  margin-top: 5px;
}
.login-error {
  background: #fef2f2;
  color: #991b1b;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  margin: 0;
}
@media (max-width: 1050px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .document-list {
    max-height: 330px;
  }
  .top-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  .topbar {
    padding: 0 16px;
  }
  .account span {
    display: none;
  }
  .layout {
    padding: 12px;
  }
  .workspace-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }
  .workspace-body {
    padding: 14px;
  }
  .actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .top-grid {
    display: block;
  }
  .summary {
    margin-top: 14px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .full {
    grid-column: auto;
  }
  .compact-actions {
    margin-top: 8px;
    flex-wrap: wrap;
  }
  .panel-title-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
