:root {
  color-scheme: light;
  --ink: #000000;
  --muted: #101010;
  --line: rgba(16, 16, 16, .18);
  --panel: #ffffff;
  --surface: #ffffff;
  --accent: #7F56D9;
  --accent-dark: #000000;
  --sidebar: #101010;
  --green: #7F56D9;
  --warn: #101010;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Aptos, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--surface);
}

.app-hidden {
  display: none !important;
}

.login-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
  background:
    linear-gradient(110deg, rgba(0,0,0,.86), rgba(16,16,16,.72)),
    radial-gradient(circle at 74% 20%, rgba(127,86,217,.5), transparent 28%),
    linear-gradient(135deg, #000000 0%, #101010 48%, #000000 100%);
}

.login-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 10%, rgba(255,255,255,.08) 10% 10.4%, transparent 10.4% 22%),
    repeating-linear-gradient(0deg, transparent 0 54px, rgba(255,255,255,.08) 55px 56px),
    radial-gradient(ellipse at 78% 58%, rgba(255,255,255,.18), transparent 18%),
    radial-gradient(ellipse at 82% 58%, rgba(0,0,0,.4), transparent 12%);
  transform: skewX(-8deg) scale(1.08);
  opacity: .72;
}

.login-page::after {
  content: "";
  position: absolute;
  right: -8vw;
  bottom: -10vh;
  width: 54vw;
  aspect-ratio: 1;
  border: 22px solid rgba(255,255,255,.12);
  border-radius: 50%;
  box-shadow: inset 0 0 0 22px rgba(127,86,217,.18), inset 0 0 0 84px rgba(255,255,255,.05);
}

.login-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.35));
}

.login-panel {
  position: relative;
  z-index: 1;
  width: min(460px, 100%);
  padding: 28px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 24px 70px rgba(0,0,0,.34);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.login-brand img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  background: #ffffff;
}

.login-brand span {
  display: block;
  margin-top: 3px;
  color: #101010;
  font-size: 12px;
}

.login-panel h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.08;
  margin-bottom: 8px;
}

.login-panel p {
  margin: 0 0 22px;
  color: #101010;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 14px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16,16,16,.04);
}

.auth-tabs button {
  padding: 8px 7px;
  border-color: transparent;
  background: transparent;
  color: #101010;
  font-size: 12px;
  font-weight: 800;
}

.auth-tabs button.active {
  background: #7F56D9;
  color: #FFFFFF;
}

.auth-panel {
  display: none;
  gap: 14px;
}

.auth-panel.active {
  display: grid;
}

.auth-status {
  min-height: 18px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 13px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover { border-color: var(--accent); }

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 760;
}

.danger {
  background: #fff;
  border-color: #000000;
  color: #000000;
  font-weight: 700;
}

.secondary {
  background: #fff;
  color: var(--accent-dark);
  font-weight: 720;
}

.small { padding: 6px 10px; font-size: 13px; }
.wide { width: 100%; }

.shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(255,255,255,.74), rgba(255,255,255,.42)),
    url("/assets/light-shed-background.png") center / cover fixed;
}

.sidebar {
  background: var(--sidebar);
  color: #fff;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255,255,255,.16);
}

.brand img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 5px;
}

.brand span {
  display: block;
  color: rgba(255,255,255,.72);
  font-size: 12px;
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

nav button {
  background: transparent;
  color: #ffffff;
  border-color: transparent;
  text-align: left;
  font-weight: 720;
}

nav button.active {
  background: #7F56D9;
  color: #fff;
}

main {
  padding: 22px;
  background: rgba(255,255,255,.28);
  backdrop-filter: blur(.5px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 780;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 {
  font-size: 28px;
  line-height: 1.12;
  font-weight: 820;
}
h2 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 800;
}

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

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

.page-actions {
  display: none;
}

.page-actions.active {
  display: flex;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sign-out {
  border-color: var(--sidebar);
  background: var(--sidebar);
  color: #ffffff;
}

.sign-out:hover {
  border-color: #7F56D9;
  background: #7F56D9;
  color: #ffffff;
}

.command-menu {
  position: relative;
}

.command-menu summary {
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 13px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 700;
  cursor: pointer;
}

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

.command-menu .primary-summary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.command-menu div {
  position: absolute;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 6px;
  min-width: 158px;
  margin-top: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
}

.command-menu button {
  width: 100%;
  text-align: left;
}

.form-menu summary {
  width: 100%;
  text-align: center;
}

.panel { display: none; }
.panel.active { display: block; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

.email-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.email-form {
  display: grid;
  gap: 12px;
}

.mail-setup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mail-setup div:first-child {
  display: grid;
  gap: 3px;
}

.mail-setup span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

section {
  background: rgba(255,255,255,.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.section-title span {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

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

.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  resize: vertical;
}

input:disabled, textarea:disabled, select:disabled {
  background: rgba(16,16,16,.05);
  color: #101010;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid rgba(127,86,217,.22);
  border-color: var(--accent);
}

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

.line-head, .line-row {
  display: grid;
  grid-template-columns: 48px minmax(230px, 1fr) 100px 82px 68px 64px 82px 86px 36px;
  gap: 8px;
  align-items: center;
  min-width: 840px;
}

.line-head {
  padding: 10px;
  background: var(--sidebar);
  color: #fff;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.line-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.line-row input {
  padding: 7px 8px;
}

.remove-line {
  padding: 7px;
  color: #000000;
}

.doc-chooser {
  display: grid;
  gap: 8px;
}

.doc-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
}

.doc-check input { width: auto; }

.form-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.form-actions > button,
.form-actions > .command-menu {
  min-width: 0;
}

.form-actions > button,
.form-actions > .command-menu summary {
  width: 100%;
}

.hidden-file {
  display: none;
}

.pdf-preview {
  width: 100%;
  height: calc(100vh - 190px);
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.table-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

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

.quote-filters {
  grid-template-columns: minmax(220px, 1.4fr) minmax(150px, .8fr) minmax(140px, .7fr) minmax(140px, .7fr);
}

.customer-form {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid rgba(127,86,217,.28);
  border-radius: 8px;
  background: rgba(255,255,255,.84);
}

.hidden-card {
  display: none;
}

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

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 18px;
  align-items: start;
}

.settings-history {
  grid-column: 1 / -1;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.logo-settings {
  display: grid;
  gap: 14px;
}

.settings-save {
  margin-top: 14px;
}

.logo-settings img {
  width: 168px;
  max-height: 120px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.crm-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.crm-table {
  width: 100%;
  min-width: 1220px;
  border-collapse: collapse;
  background: #fff;
}

.crm-table th,
.crm-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.crm-table th {
  background: rgba(127,86,217,.08);
  color: var(--accent-dark);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 800;
}

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

.crm-table td {
  font-size: 13px;
  white-space: pre-wrap;
}

.empty-table {
  color: var(--muted);
  text-align: center;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(127,86,217,.1);
  color: #000000;
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 1120px) {
  .shell { grid-template-columns: 210px minmax(0, 1fr); }
  .topbar { grid-template-columns: 1fr; }
  .topbar-actions,
  .actions { justify-content: flex-start; }
  .layout,
  .email-layout { grid-template-columns: 1fr; }
  .documents { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
  .documents section { margin-bottom: 0; }
  .four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .table-filters,
  .customer-filters,
  .quote-filters { grid-template-columns: 1fr; }
}

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

.revision {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}
