@import url("https://fonts.googleapis.com/css2?family=Exo+2:wght@300;400;500;600;700&family=Montserrat:wght@600;700;800&display=swap");

:root {
  --dark: #0f0a08;
  --dark-soft: #1a1210;
  --accent: #f37935;
  --accent-hover: #e25a0d;
  --gold: #fb8b00;
  --text: #2a2a2a;
  --muted: #6b6b6b;
  --white: #fff;
  --bg: #f4f1ec;
  --card: #fff;
  --border: #e8e0d8;
  --danger: #b42318;
  --ok: #1a8f4a;
  --primary: var(--accent);
  --primary-hover: var(--accent-hover);
  --shadow: 0 8px 32px rgba(15, 10, 8, 0.12);
  --radius: 8px;
  --radius-lg: 16px;
  --header-h: 72px;
  --font-head: "Montserrat", sans-serif;
  --font-body: "Exo 2", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 18px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
}

.hidden {
  display: none !important;
}

h1,
h2,
h3,
.brand-name,
.btn,
.tab,
.page-kicker {
  font-family: var(--font-head);
}

h1,
h2 {
  margin: 0 0 12px;
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.7rem, 2.2vw, 2.15rem);
}

h2 {
  font-size: 1.25rem;
}

.page-kicker {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--white);
  min-width: 0;
}

.brand:hover {
  color: var(--white);
}

.brand-logo {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: block;
  border-radius: 8px;
  object-fit: cover;
  background: #000;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-weight: 700;
  font-size: 18px;
}

.brand-sub {
  font-family: var(--font-body);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.62);
  font-weight: 400;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: var(--header-h);
  padding: 12px 24px;
  background: rgba(15, 10, 8, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--white);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(12px);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav a {
  padding: 8px 12px;
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 16px;
}

.nav a.active,
.nav a:hover {
  background: transparent;
  color: var(--accent);
}

.nav .user-login {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  margin-left: 8px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(15, 10, 8, 0.82), rgba(15, 10, 8, 0.88)),
    radial-gradient(900px 480px at 18% 30%, rgba(243, 121, 53, 0.22), transparent 55%),
    #1a1210;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  margin: 0;
  position: relative;
  z-index: 1;
}

.login-card h1 {
  color: var(--accent);
  margin-bottom: 8px;
}

.login-card .login-pill {
  display: inline-block;
  margin: 0 0 14px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(243, 121, 53, 0.12);
  color: var(--accent-hover);
  font-size: 13px;
  font-weight: 600;
}

.login-wrap .brand {
  position: absolute;
  top: 20px;
  left: 24px;
}

.page {
  padding: 28px 24px 48px;
  max-width: 1280px;
  margin: 0 auto;
}

.layout {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

section {
  margin-bottom: 24px;
}

label,
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 1.05rem;
  margin-bottom: 12px;
}

input,
textarea,
select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: #fff;
  color: var(--text);
}

input:focus,
textarea:focus,
select:focus {
  outline: 2px solid rgba(243, 121, 53, 0.28);
  border-color: var(--accent);
}

input[type="checkbox"],
input[type="radio"] {
  width: 1.15em;
  height: 1.15em;
  accent-color: var(--accent);
}

input:read-only {
  background: #f7f4f1;
  color: var(--muted);
}

#frame-wrap span,
.field span {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 700px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius);
  padding: 11px 18px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s, color 0.2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary,
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(243, 121, 53, 0.35);
}

.btn-primary:hover,
.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-ghost,
.btn.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover,
.btn.secondary:hover {
  border-color: var(--dark);
  background: #fff;
}

.topbar .btn-ghost {
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.18);
  background: transparent;
}

.topbar .btn-ghost:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.06);
}

.btn-danger,
.btn.danger {
  background: #fff4f2;
  color: var(--danger);
  border-color: #f4d0cb;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 700;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}

a.btn {
  text-decoration: none;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--danger);
  margin-top: 8px;
}

.ok {
  color: var(--ok);
}

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

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

.filters input,
.filters select {
  width: auto;
  min-width: 180px;
  background: #fff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
}

.data-table th {
  font-family: var(--font-head);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  background: #faf7f4;
}

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

.data-table tbody tr:hover {
  background: #fff8f3;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  background: #fff3ea;
  color: var(--accent-hover);
}

.badge.draft {
  background: #fffaeb;
  color: #b54708;
}

.badge.saved {
  background: #ecfdf3;
  color: var(--ok);
}

.type-groups {
  display: grid;
  gap: 18px;
}

.type-group {
  padding: 14px 14px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #faf7f4;
}

.type-group__title {
  margin: 0 0 10px;
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
}

.type-grid {
  display: grid;
  gap: 8px;
}

.type-option {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  background: #fff;
  font-size: 1.125rem;
  line-height: 1.4;
  transition: border-color 0.15s, background 0.15s;
}

.type-option:hover {
  border-color: #f0c4a8;
}

.type-option:has(input:checked) {
  border-color: var(--accent);
  background: #fff6ef;
  box-shadow: 0 0 0 3px rgba(243, 121, 53, 0.12);
}

.wizard-card {
  max-width: 720px;
}

.wizard-card .wizard-title {
  text-align: center;
  margin-bottom: 24px;
}

.wizard-types-block.hidden {
  display: none;
}

.contractor-types {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px 14px;
  margin: 0 0 12px;
}

.contractor-types legend {
  padding: 0 6px;
  font-weight: 700;
}

.contractor-types-grid {
  display: grid;
  gap: 8px;
}

.contractor-types-grid label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-weight: 500;
  cursor: pointer;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

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

.items-table {
  width: 100%;
  border-collapse: collapse;
}

.items-table th,
.items-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px;
  text-align: left;
}

.items-table input {
  min-width: 80px;
}

.items-table .item-code {
  width: 56px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.items-table tr.calc-section td {
  background: #f7f3ee;
}

.items-table tr.calc-section input {
  font-weight: 700;
}

.items-table tr.is-current {
  outline: 2px solid rgba(243, 121, 53, 0.35);
  outline-offset: -2px;
}

.totals {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-weight: 600;
}

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

.save-state {
  font-size: 0.95rem;
}

.preview-panel {
  position: sticky;
  top: calc(var(--header-h) + 12px);
  min-height: calc(100vh - var(--header-h) - 32px);
  display: flex;
  flex-direction: column;
}

.preview-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#preview-frame,
.preview-edit {
  flex: 1;
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.preview-edit {
  padding: 16px 20px;
  overflow: auto;
  font-family: "Times New Roman", Times, serif;
  font-size: 12pt;
  line-height: 1.35;
}

.edit-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.form-hint {
  margin: -4px 0 10px;
  font-size: 0.95rem;
}

.row-remove {
  background: transparent;
  border: 0;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
}

.meta-line {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  align-items: center;
}

.modal-back {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 10, 8, 0.55);
  z-index: 40;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-back.open {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: min(560px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.viz-link {
  font-size: 0.9rem;
  word-break: break-all;
}

.signature-preview {
  display: block;
  max-height: 80px;
  max-width: 220px;
  margin: 0 0 8px;
  padding: 8px;
  background: #f7f4f1;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    height: auto;
  }
}
