:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface2: #eef5f3;
  --text: #0f172a;
  --muted: #64748b;
  --border: #d7e3df;
  --brand: #0f766e;
  --brand-dark: #0b5a54;
  --brand-soft: #ccfbf1;
  --danger: #dc2626;
  --gold: #b45309;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(15, 118, 110, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% -10%, #d8f3ee 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #e8eefc 0%, transparent 45%),
    var(--bg);
}

h1, h2, h3, .brand-mark { font-family: Fraunces, Georgia, serif; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; }
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 10px; font-size: .85rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-size: .85rem; color: var(--muted); font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text);
}
.field textarea { min-height: 84px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.msg { padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.msg-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.msg-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

/* Landing */
.landing { min-height: 100vh; }
.landing-nav {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px clamp(16px, 4vw, 48px);
}
.brand {
  display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(145deg, #14b8a6, #0f766e); color: #fff; font-size: 1rem;
}
.hero {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 36px;
  padding: 24px clamp(16px, 4vw, 48px) 64px; align-items: center;
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; } }
.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; margin: 0 0 16px;
  letter-spacing: -.02em;
}
.hero p { color: var(--muted); font-size: 1.08rem; max-width: 34rem; line-height: 1.55; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.hero-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: var(--shadow); padding: 22px; min-height: 360px;
  background-image:
    linear-gradient(180deg, rgba(15,118,110,.06), transparent 40%),
    linear-gradient(#fff, #fff);
}
.doc-preview-top { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.doc-preview-badge {
  background: var(--brand-soft); color: var(--brand-dark); font-weight: 700;
  font-size: .75rem; padding: 4px 10px; border-radius: 999px; letter-spacing: .04em;
}
.preview-line { height: 10px; background: #e2e8f0; border-radius: 6px; margin: 8px 0; }
.preview-line.short { width: 45%; }
.preview-table { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 12px; }
.feature-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  padding: 0 clamp(16px, 4vw, 48px) 64px;
}
@media (max-width: 800px) { .feature-row { grid-template-columns: 1fr; } }
.feature {
  background: rgba(255,255,255,.8); border: 1px solid var(--border); border-radius: 16px; padding: 18px;
}
.feature h3 { margin: 0 0 8px; font-size: 1.1rem; }
.feature p { margin: 0; color: var(--muted); font-size: .92rem; }

/* Auth card */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 28px; box-shadow: var(--shadow);
}
.auth-card h1 { margin: 0 0 6px; font-size: 1.8rem; }
.auth-card .sub { color: var(--muted); margin-bottom: 18px; }
.auth-foot { margin-top: 14px; color: var(--muted); font-size: .9rem; }

/* App shell */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
@media (max-width: 860px) { .app-shell { grid-template-columns: 1fr; } }
.sidebar {
  background: #083b37; color: #ecfdf5; padding: 22px 16px; display: flex; flex-direction: column; gap: 8px;
}
.sidebar .brand { color: #fff; margin-bottom: 18px; }
.nav-btn {
  text-align: left; background: transparent; border: none; color: #99f6e4; padding: 11px 12px;
  border-radius: 10px; cursor: pointer; font-weight: 600;
}
.nav-btn.active, .nav-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); }
.main { padding: 22px clamp(14px, 3vw, 28px); }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 1.7rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: 1fr 1fr; } }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  box-shadow: 0 4px 18px rgba(15, 23, 42, 0.03);
}
.kpi .val { font-size: 1.5rem; font-weight: 700; }
.kpi .lbl { color: var(--muted); font-size: .85rem; margin-top: 4px; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 16px;
  margin-bottom: 16px;
}
.panel h2 { margin: 0 0 12px; font-size: 1.15rem; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.data th { background: var(--surface2); color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
.badge {
  display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: .72rem; font-weight: 700;
  background: var(--brand-soft); color: var(--brand-dark);
}
.badge-qtn { background: #eff6ff; color: #1d4ed8; }
.badge-mrv { background: #fff7ed; color: #c2410c; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center;
  justify-content: center; padding: 16px; z-index: 50;
}
.modal {
  width: min(760px, 100%); max-height: 92vh; overflow: auto; background: #fff;
  border-radius: 18px; padding: 20px; border: 1px solid var(--border);
}
.modal h2 { margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.items-table input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.thumb { max-width: 120px; max-height: 80px; border-radius: 8px; border: 1px solid var(--border); }
.muted { color: var(--muted); }
.empty { text-align: center; padding: 28px; color: var(--muted); }
