:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f0f4f8;
  --ink: #17202a;
  --muted: #667085;
  --line: #e3e8ef;
  --brand: #1f7a6d;
  --brand-2: #255f85;
  --accent: #c67b32;
  --danger: #c2413a;
  --warning: #b7791f;
  --success: #16845f;
  --shadow: 0 20px 60px rgba(16, 24, 40, .08);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(340px, 520px) 1fr;
  background: #0f1f2b;
}
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
  background: var(--panel);
}
.auth-visual {
  position: relative;
  overflow: hidden;
  padding: 48px;
  color: #fff;
  background:
    linear-gradient(rgba(15, 31, 43, .58), rgba(15, 31, 43, .70)),
    url("https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=1600&q=80") center/cover;
}
.auth-visual h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(38px, 5vw, 72px);
  line-height: 1;
}
.auth-visual p { max-width: 620px; color: rgba(255,255,255,.78); font-size: 18px; }
.logo-row { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: var(--radius); background: var(--brand); color: #fff; font-weight: 800;
}
.auth-card h2 { margin: 0 0 8px; font-size: 28px; }
.auth-card p { color: var(--muted); margin: 0 0 24px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 268px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  background: #111c24; color: #fff; display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto;
}
.sidebar .logo-row { margin-bottom: 4px; padding: 0 8px; }
.sidebar small { color: rgba(255,255,255,.55); }
.nav { display: grid; gap: 4px; }
.nav button {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border: 0; border-radius: var(--radius); color: rgba(255,255,255,.72); background: transparent; text-align: left;
}
.nav button:hover, .nav button.active { background: rgba(255,255,255,.10); color: #fff; }
.nav svg, .icon { width: 18px; height: 18px; flex: 0 0 18px; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255,255,255,.10); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 72px; padding: 0 28px; background: rgba(246,247,249,.9); backdrop-filter: blur(16px); border-bottom: 1px solid var(--line);
}
.searchbar { flex: 1; max-width: 560px; position: relative; }
.searchbar input { width: 100%; padding: 12px 14px 12px 40px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.searchbar .icon { position: absolute; left: 14px; top: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 10px; align-items: center; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--brand-2); color: #fff; display: grid; place-items: center; font-weight: 800; }

.content { padding: 28px; max-width: 1640px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 30px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16,24,40,.04); padding: 18px;
}
.metric { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.metric b { display: block; font-size: 28px; margin-top: 8px; }
.metric span, .muted { color: var(--muted); }
.metric .brand-mark { background: var(--panel-2); color: var(--brand); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 16px; }
.toolbar input, .toolbar select, .field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fff; color: var(--ink);
}
.field textarea { min-height: 86px; resize: vertical; }
.field label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; font-weight: 700; text-transform: uppercase; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); padding: 9px 13px; font-weight: 700;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { background: #fff5f5; color: var(--danger); border-color: #f1c3c0; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 40px; padding: 0; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; background: #fbfcfd; }
tr:hover td { background: #fbfcfd; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; background: var(--panel-2); color: var(--brand-2); }
.pill.success { background: #e7f7ef; color: var(--success); }
.pill.warning { background: #fff5df; color: var(--warning); }
.pill.danger { background: #fff0ef; color: var(--danger); }
.pill.neutral { background: #edf1f5; color: #475467; }

.split { display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; align-items: start; }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 14px; overflow: auto; }
.kanban-col { background: #eef2f6; border-radius: var(--radius); padding: 12px; min-height: 240px; }
.kanban-col h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.kanban-item { padding: 12px; border: 1px solid var(--line); background: #fff; border-radius: var(--radius); margin-bottom: 10px; }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: #e8edf2; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .25s ease; }

.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 12px 10px; color: var(--muted); font-weight: 800; white-space: nowrap; }
.tabs button.active { color: var(--brand); box-shadow: inset 0 -2px var(--brand); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(17,28,36,.48); }
.modal {
  width: min(1040px, 100%); max-height: 92vh; overflow: auto; background: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line);
}
.modal.small { width: min(560px, 100%); }
.modal-head, .modal-foot { position: sticky; background: #fff; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-foot { bottom: 0; border-top: 1px solid var(--line); border-bottom: 0; justify-content: flex-end; }
.modal-body { padding: 18px; }

.timeline { position: relative; display: grid; gap: 12px; }
.timeline-item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; }
.dot { width: 12px; height: 12px; margin: 4px auto 0; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 4px #e7f4f1; }
.timeline-item .card { padding: 12px; }
.doc-preview { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: var(--radius); background: #f8fafc; }
.empty { display: grid; place-items: center; min-height: 220px; border: 1px dashed #cbd5e1; border-radius: var(--radius); color: var(--muted); text-align: center; padding: 24px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 80; padding: 12px 14px; border-radius: var(--radius); background: #111c24; color: #fff; box-shadow: var(--shadow); animation: rise .25s ease; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.branding-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.brand-card h2 { margin-top: 0; }
.upload-zone {
  position: relative; display: grid; place-items: center; min-height: 120px; padding: 14px;
  border: 1px dashed #b8c2cc; border-radius: var(--radius); background: #fbfcfd; text-align: center; overflow: hidden;
}
.upload-zone.small { min-height: 86px; }
.upload-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-zone img { max-width: 100%; max-height: 86px; object-fit: contain; }
.theme-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.color-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.color-field { display: grid; grid-template-columns: 44px 1fr 34px; gap: 8px; align-items: center; }
.color-field label { grid-column: 1 / -1; }
.color-field input[type="color"] { height: 42px; padding: 3px; }
.color-field span { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); }
.toggle-row { display: flex; gap: 10px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: #fbfcfd; font-weight: 700; }
.toggle-row input { width: 18px; height: 18px; }
.preview-card { grid-row: span 2; }
.mini-app { display: grid; grid-template-columns: 150px 1fr; min-height: 260px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.mini-app aside { color: #fff; padding: 18px; display: grid; align-content: start; gap: 12px; }
.mini-app main { padding: 18px; display: grid; align-content: start; gap: 14px; }
.mini-app button { width: max-content; border: 0; border-radius: var(--radius); color: #fff; padding: 10px 14px; font-weight: 800; }
.mini-card, .mini-top { border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius); padding: 14px; }
.actions-card { display: flex; gap: 10px; align-items: center; justify-content: flex-end; grid-column: 1 / -1; }

@media (max-width: 1060px) {
  .app-shell { grid-template-columns: 80px 1fr; }
  .sidebar { padding: 16px 10px; }
  .sidebar .logo-row div:not(.brand-mark), .nav span, .sidebar-foot { display: none; }
  .nav button { justify-content: center; }
  .kpis, .split { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 2; }
}
@media (max-width: 720px) {
  .auth-shell, .app-shell, .kpis, .split, .form-grid { grid-template-columns: 1fr; }
  .auth-visual { min-height: 360px; order: -1; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; }
  .sidebar .logo-row { min-width: 58px; }
  .nav { grid-auto-flow: column; grid-auto-columns: 48px; }
  .main { min-width: 0; }
  .topbar { height: auto; padding: 14px; align-items: stretch; flex-direction: column; }
  .content { padding: 18px 14px; }
  .page-head { flex-direction: column; }
  .span-2, .span-3 { grid-column: span 1; }
  .kanban { grid-template-columns: 1fr; }
  .branding-grid, .color-grid, .mini-app { grid-template-columns: 1fr; }
  .actions-card { justify-content: stretch; flex-direction: column; }
  .actions-card .btn { width: 100%; }
}
