:root {
  --ink: #1F1D1B;
  --ink-2: #4A443E;
  --muted: #7C7268;
  --paper: #F6F1EA;
  --card: #FFFFFF;
  --line: #E4D9CB;
  --line-2: #D3C3AF;
  --walnut: #7A5C43;
  --walnut-dark: #654A35;
  --brass: #B08D57;
  --brass-soft: #EFE2CC;
  --success: #3F6B4F;
  --success-soft: #E3EEE6;
  --warning: #B07A2E;
  --warning-soft: #F7ECD9;
  --danger: #A6432F;
  --danger-soft: #F6E2DD;
  --shadow: 0 10px 30px rgba(55, 40, 28, .08);
  --shadow-sm: 0 3px 10px rgba(55, 40, 28, .07);
  --radius: 14px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --font-sans: "Segoe UI", "Gill Sans", "Trebuchet MS", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { max-width: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.55 var(--font-sans);
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 21px; }
h3 { font-size: 17px; }
p { margin: 0; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--walnut); }

.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--ink);
  color: #F4ECE0;
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
}

.brand { display: flex; gap: 12px; align-items: center; min-width: 0; }
.brand img { flex: none; border-radius: 12px; }
.brand strong { display: block; font-family: var(--font-serif); font-size: 16px; line-height: 1.15; }
.brand span { display: block; font-size: 11px; color: #C9B9A4; margin-top: 4px; line-height: 1.3; }

.nav { display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: transparent;
  color: #E9DFD1;
  padding: 10px 11px;
  border-radius: 10px;
  text-align: left;
  min-width: 0;
  transition: background .15s ease, color .15s ease;
}
.nav-item img { flex: none; opacity: .95; }
.nav-item span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: rgba(255, 255, 255, .07); }
.nav-item.active { background: var(--brass); color: #241B12; font-weight: 600; }
.nav-item.disabled { opacity: .4; cursor: not-allowed; }
.nav-item.disabled:hover { background: transparent; }
.nav-badge {
  background: var(--brass);
  color: #241B12;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}
.nav-item.active .nav-badge { background: var(--ink); color: #F4ECE0; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }
.admin-link {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #E9DFD1;
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 13px;
  text-align: left;
}
.admin-link:hover { background: rgba(255, 255, 255, .1); }
.admin-link.disabled { opacity: .4; cursor: not-allowed; }
.role-switch { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: #C9B9A4; text-transform: uppercase; letter-spacing: .06em; }
.role-switch select {
  width: 100%;
  background: #2B2724;
  color: #F4ECE0;
  border: 1px solid #4A423B;
  border-radius: 9px;
  padding: 8px 9px;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}
.demo-note { font-size: 11px; color: #9E9080; line-height: 1.35; }

/* ---------- Main / topbar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  background: rgba(246, 241, 234, .93);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.topbar-title { min-width: 0; }
.eyebrow { display: block; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 2px; }
.topbar h1 { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 9px; flex: none; }
.role-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 12px 4px 5px;
  font-size: 13px;
  box-shadow: var(--shadow-sm);
  max-width: 210px;
}
.role-chip img { border-radius: 50%; }
.role-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  position: relative;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.icon-btn:hover { border-color: var(--brass); }
.dot-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 10px; line-height: 18px; text-align: center;
  border: 2px solid var(--paper);
}

.view {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 26px 48px;
  min-width: 0;
  outline: none;
}
.loading { color: var(--muted); padding: 40px; text-align: center; }

/* ---------- Common ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  background: var(--walnut);
  color: #fff;
  white-space: nowrap;
  transition: background .15s ease, transform .05s ease;
}
.btn:hover { background: var(--walnut-dark); }
.btn:active { transform: translateY(1px); }
.btn img { flex: none; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #FBF7F1; border-color: var(--brass); }
.btn-brass { background: var(--brass); color: #241B12; }
.btn-brass:hover { background: #9B7A46; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #8C3827; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, .nav-item:focus-visible, .role-chip:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid rgba(176, 141, 87, .45);
  outline-offset: 2px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-bottom: 16px;
  min-width: 0;
}
.toolbar .spacer { flex: 1; }
.search-box { position: relative; flex: 1 1 220px; min-width: 160px; max-width: 360px; }
.search-box input { padding-left: 34px; }
.search-box::before {
  content: "";
  position: absolute; left: 12px; top: 50%; width: 12px; height: 12px;
  border: 2px solid var(--muted); border-radius: 50%;
  transform: translateY(-60%);
}
.search-box::after {
  content: ""; position: absolute; left: 23px; top: 55%; width: 6px; height: 2px;
  background: var(--muted); transform: rotate(45deg);
}

input[type="text"], input[type="search"], input[type="tel"], input[type="email"],
input[type="date"], input[type="datetime-local"], input[type="number"], input[type="file"],
select, textarea {
  width: 100%;
  border: 1px solid var(--line-2);
  background: var(--card);
  border-radius: 9px;
  padding: 8px 10px;
  min-height: 38px;
  min-width: 0;
}
textarea { resize: vertical; min-height: 76px; }
input[type="date"], input[type="datetime-local"] { min-height: 38px; }
.toolbar select, .toolbar input { width: auto; min-width: 130px; }
.toolbar .search-box input { width: 100%; }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  min-width: 0;
}
.panel.pad-sm { padding: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-width: 0; }
.panel-head h2, .panel-head h3 { min-width: 0; }
.panel-head .hint { font-size: 12px; color: var(--muted); }
.grid { display: grid; gap: 16px; min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-dash { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.row { display: flex; gap: 10px; align-items: center; min-width: 0; }
.wrap { flex-wrap: wrap; }

.kpi-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px 15px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  content: ""; position: absolute; right: -18px; bottom: -26px;
  width: 70px; height: 70px; border-radius: 50%;
  background: var(--brass-soft); opacity: .55;
}
.kpi.clickable:hover { border-color: var(--brass); }
.kpi .label { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; position: relative; z-index: 1; }
.kpi .value { display: block; font-family: var(--font-serif); font-size: 25px; line-height: 1.1; position: relative; z-index: 1; }
.kpi .sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 5px; position: relative; z-index: 1; }
.kpi.alert { border-color: #E9B9A9; background: #FFF8F5; }
.kpi.alert .value { color: var(--danger); }
.kpi.warn { border-color: #ECD2A7; background: #FFFBF3; }
.kpi.warn .value { color: var(--warning); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data { min-width: 760px; }
th, td { text-align: left; padding: 10px 11px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  position: sticky; top: 0; z-index: 2;
  background: #FBF7F1; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600;
  white-space: nowrap;
}
tbody tr:hover { background: #FCF9F4; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 11.5px; }
.cell-ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.row-low td { background: #FFF5F1; }
.row-low:hover td { background: #FDEDE7; }
tr.clickable { cursor: pointer; }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty img { width: min(280px, 100%); display: block; margin: 0 auto 14px; border-radius: 14px; }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 420px; margin: 0 auto 14px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 3px 9px; font-size: 11.5px; font-weight: 600;
  background: #F1EAE0; color: var(--ink-2); white-space: nowrap;
  border: 1px solid transparent;
}
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.warn { background: var(--warning-soft); color: var(--warning); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.brass { background: var(--brass-soft); color: #6E5329; }
.badge.dark { background: #EAE4DA; color: var(--ink); }
.badge.vip { background: #2F2A25; color: #EBD3A5; }
.tag { font-size: 11px; color: var(--muted); }

/* ---------- Kanban ---------- */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  align-items: flex-start;
  padding: 2px 2px 14px;
  max-width: 100%;
  scrollbar-color: var(--brass) #EDE4D8;
}
.kanban-col {
  flex: 0 0 292px;
  width: 292px;
  background: #EFE7DC;
  border: 1px solid #E0D3C2;
  border-radius: 13px;
  padding: 9px;
  max-height: 620px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.kanban-col.drag-over { outline: 2px dashed var(--brass); outline-offset: -3px; background: #F5EDE1; }
.kanban-head { display: flex; align-items: center; gap: 7px; padding: 2px 2px 9px; min-width: 0; }
.kanban-head h3 { font-size: 13px; font-family: var(--font-sans); font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-count { font-size: 11px; background: #fff; border-radius: 999px; padding: 1px 7px; color: var(--muted); }
.kanban-add { border: 0; background: transparent; color: var(--walnut); font-size: 18px; line-height: 1; padding: 0 3px; border-radius: 6px; }
.kanban-add:hover { background: rgba(122, 92, 67, .12); }
.kanban-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding: 1px; min-height: 60px; }
.k-card {
  background: #fff;
  border: 1px solid #E2D6C6;
  border-left: 4px solid var(--brass);
  border-radius: 10px;
  padding: 10px 11px;
  box-shadow: 0 2px 5px rgba(55, 40, 28, .05);
  cursor: grab;
  min-width: 0;
}
.k-card:hover { border-color: var(--walnut); box-shadow: var(--shadow-sm); }
.k-card:active { cursor: grabbing; }
.k-card.dragging { opacity: .45; transform: rotate(.5deg); }
.k-card.overdue { border-left-color: var(--danger); }
.k-card.vip { border-left-color: var(--ink); background: linear-gradient(180deg, #FFFDF9, #FFF); }
.k-top { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-bottom: 4px; }
.k-num { font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }
.k-client { font-size: 13.5px; font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-meta { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.k-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 7px; font-size: 11.5px; color: var(--muted); }
.k-amount { font-weight: 700; color: var(--ink); white-space: nowrap; }
.k-deadline.overdue { color: var(--danger); font-weight: 700; }
.k-mini { display: flex; gap: 2px; margin-top: 7px; }
.k-mini i { display: block; height: 4px; flex: 1; border-radius: 2px; background: #E9DFD2; }
.k-mini i.done { background: var(--success); }
.k-mini i.active { background: var(--brass); }
.k-labels { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

/* ---------- Progress / stages ---------- */
.progress-line { display: flex; align-items: center; gap: 9px; min-width: 120px; }
.progress-line .bar { flex: 1; height: 7px; background: #EEE5D9; border-radius: 999px; overflow: hidden; min-width: 50px; }
.progress-line .bar b { display: block; height: 100%; background: var(--brass); border-radius: 999px; }
.progress-line .pct { font-size: 11px; color: var(--muted); white-space: nowrap; }
.segbar { display: flex; gap: 3px; margin-top: 4px; }
.segbar i { flex: 1; height: 7px; background: #EDE4D7; border-radius: 2px; }
.segbar i.done { background: var(--success); }
.segbar i.active { background: var(--brass); }
.stage-list { display: flex; flex-direction: column; gap: 8px; }
.stage-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  background: #FDFBF8;
}
.stage-row.done { background: #F4F9F5; border-color: #C9DCCF; }
.stage-row.active { background: #FCF6EA; border-color: #E4CB9F; }
.stage-name { font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.stage-actions { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Calendar ---------- */
.calendar-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; min-width: 0; }
.cal-dow { font-size: 11px; text-transform: uppercase; color: var(--muted); text-align: center; padding: 4px 0; letter-spacing: .05em; }
.cal-day {
  background: #FDFBF7; border: 1px solid var(--line); border-radius: 9px;
  min-height: 96px; padding: 5px 6px; min-width: 0; text-align: left;
  display: flex; flex-direction: column; gap: 3px;
}
.cal-day:hover { border-color: var(--brass); }
.cal-day.out { opacity: .45; background: #F8F4EE; }
.cal-day.today { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); }
.cal-day .d { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.cal-ev {
  display: block; font-size: 10.5px; line-height: 1.25; border-radius: 5px;
  padding: 2px 4px; background: var(--brass-soft); color: #5F4827;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-left: 3px solid var(--brass);
}
.cal-ev.t-measure { background: #E7EEF7; border-color: #4C6E9A; color: #33475F; }
.cal-ev.t-approval { background: #F2E7F6; border-color: #7D5A8F; color: #4E3658; }
.cal-ev.t-production { background: #F7ECD9; border-color: var(--warning); color: #6D4C1B; }
.cal-ev.t-delivery { background: #E3EEE6; border-color: var(--success); color: #2C4C38; }
.cal-ev.t-payment { background: #EFE2CC; border-color: var(--walnut); color: #5A422C; }
.cal-ev.cancelled { text-decoration: line-through; opacity: .6; }
.list-event { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.list-event:last-child { border-bottom: 0; }
.event-date { flex: none; width: 74px; font-size: 11.5px; color: var(--muted); }
.event-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brass); margin-top: 5px; flex: none; }

/* ---------- Notifications / channels ---------- */
.notif-list { display: flex; flex-direction: column; }
.notif-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 4px;
  border-bottom: 1px solid var(--line); text-align: left; background: transparent; border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: #FCF8F2; }
.notif-item.unread { background: #FFFAF1; }
.notif-item.unread .notif-title { font-weight: 700; }
.notif-ico { flex: none; width: 34px; height: 34px; border-radius: 10px; background: var(--brass-soft); display: grid; place-items: center; }
.notif-ico img { width: 20px; height: 20px; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 13.5px; }
.notif-text { font-size: 12px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.notif-meta { flex: none; font-size: 11px; color: var(--muted); text-align: right; }
.channel-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.channel-row:last-child { border-bottom: 0; }
.channel-copy { min-width: 0; }
.channel-copy strong { display: block; font-size: 14px; }
.channel-copy span { display: block; font-size: 12px; color: var(--muted); }
.switch { position: relative; display: inline-flex; flex: none; width: 46px; height: 26px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i { width: 46px; height: 26px; border-radius: 999px; background: #D8CBBB; transition: background .15s; }
.switch i::after { content: ""; display: block; width: 20px; height: 20px; margin: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + i { background: var(--success); }
.switch input:checked + i::after { transform: translateX(20px); }
.switch input:focus-visible + i { outline: 3px solid rgba(176, 141, 87, .45); outline-offset: 2px; }
.log-list { display: flex; flex-direction: column; gap: 0; }
.log-row { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12.5px; align-items: flex-start; }
.log-row:last-child { border-bottom: 0; }
.log-channel { flex: none; width: 70px; }
.log-text { flex: 1; min-width: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.log-date { flex: none; color: var(--muted); font-size: 11px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(31, 29, 27, .52);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 26px 14px; overflow-y: auto;
}
.modal {
  background: var(--paper);
  border-radius: 18px;
  width: min(880px, 100%);
  max-width: 100%;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .25);
  overflow: hidden;
  margin: auto 0;
}
.modal.wide { width: min(1060px, 100%); }
.modal.narrow { width: min(560px, 100%); }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); background: var(--card);
}
.modal-head h2 { font-size: 20px; }
.modal-head p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.modal-close { border: 0; background: #F1E9DF; color: var(--ink); width: 34px; height: 34px; border-radius: 9px; font-size: 20px; line-height: 1; flex: none; }
.modal-close:hover { background: #E6D9C8; }
.modal-body { padding: 18px 20px 22px; max-height: calc(100vh - 150px); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 20px; border-top: 1px solid var(--line); background: var(--card); flex-wrap: wrap; }
.lead-dialog[hidden] { display: none; }
.type-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.type-tile { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 9px 4px; font-size: 11.5px; color: var(--ink-2); text-align: center; }
.type-tile img { width: 36px; height: 36px; object-fit: contain; }
@media (max-width: 620px) { .type-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 15px; }
.tab { border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 7px 11px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.tab:hover { background: #EFE7DC; }
.tab.active { background: var(--ink); color: #F6F1EA; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > span { font-weight: 600; }
.field .req { color: var(--danger); }
.field small { color: var(--muted); font-size: 11px; }
.check-row { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--ink-2); }
.check-row input { width: auto; min-height: auto; margin-top: 3px; }
.form-error { color: var(--danger); font-size: 11.5px; min-height: 14px; }
.form-status { margin-top: 10px; font-size: 13px; }
.form-status.ok { color: var(--success); font-weight: 600; }
.form-status.err { color: var(--danger); font-weight: 600; }

.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.info-box { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; min-width: 0; }
.info-box .lbl { display: block; font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 3px; }
.info-box .val { font-size: 13.5px; overflow-wrap: anywhere; }
.info-box .val.big { font-family: var(--font-serif); font-size: 19px; }

.version-list { display: flex; flex-direction: column; gap: 10px; }
.version {
  border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; background: var(--card);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start;
}
.version.approved { border-color: #AFCDB7; background: #F6FBF7; }
.version.rejected { border-color: #E3B7AC; background: #FFF8F6; }
.version.pending { border-color: #E4CB9F; background: #FFFCF5; }
.version .v-head { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.version .v-file { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }
.version .v-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.version .v-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; max-width: 240px; }
.upload-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; padding: 11px; border: 1px dashed var(--line-2); border-radius: 10px; background: #FCF8F2; }
.upload-row input[type="file"] { max-width: 280px; flex: 1 1 200px; }
.upload-row .hint { flex: 1 1 220px; font-size: 11.5px; color: var(--muted); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 9px; margin-top: 10px; }
.photo-card { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; min-width: 0; }
.photo-card img { display: block; width: 100%; height: 96px; object-fit: cover; background: #F0E8DD; }
.photo-card figcaption { font-size: 11px; padding: 5px 7px; color: var(--ink-2); overflow-wrap: anywhere; }
.approved-note { display: flex; gap: 8px; align-items: center; background: var(--success-soft); color: var(--success); border: 1px solid #C5DACB; border-radius: 9px; padding: 9px 11px; font-size: 12.5px; margin-bottom: 12px; }
.warn-note { display: flex; gap: 8px; align-items: center; background: var(--warning-soft); color: #7A551F; border: 1px solid #E6CEA2; border-radius: 9px; padding: 9px 11px; font-size: 12.5px; margin-bottom: 12px; }

/* ---------- Login / admin ---------- */
.login-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.login-card {
  border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 12px;
  text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.login-card:hover { border-color: var(--brass); box-shadow: var(--shadow-sm); }
.login-card img { border-radius: 50%; }
.login-card strong { font-size: 13.5px; }
.login-card span { font-size: 11px; color: var(--muted); }
.login-card.active { border-color: var(--walnut); background: #FFFBF5; }
.admin-table { width: 100%; min-width: 520px; }
.admin-table select { min-width: 140px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px);
  background: var(--ink); color: #F6F1EA; border-radius: 11px; padding: 11px 16px;
  font-size: 13px; box-shadow: var(--shadow); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  max-width: min(520px, calc(100vw - 28px)); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

/* ---------- Public lead screen ---------- */
.public-lead { min-height: 100vh; background: var(--paper); padding: 20px clamp(14px, 4vw, 48px) 48px; }
.public-lead[hidden] { display: none; }
.public-topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; max-width: 1120px; margin: 0 auto 26px; }
.public-brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); min-width: 0; }
.public-brand img { border-radius: 12px; flex: none; }
.public-brand strong { display: block; font-family: var(--font-serif); font-size: 16px; }
.public-brand small { display: block; font-size: 11px; color: var(--muted); }
.public-lead-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 26px; align-items: start; max-width: 1120px; margin: 0 auto; }
.public-lead-aside { min-width: 0; }
.public-lead-aside h1 { font-size: clamp(26px, 3.4vw, 38px); line-height: 1.12; margin: 8px 0 12px; }
.public-lead-aside > p { color: var(--ink-2); font-size: 14px; max-width: 46ch; }
.public-illustration { display: block; width: 100%; max-width: 360px; height: auto; margin: 20px 0 16px; }
.public-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.public-points li { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-2); }
.public-points img { flex: none; }
.public-lead-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: clamp(16px, 2.4vw, 26px); min-width: 0; }
.public-lead-card h2 { font-size: 22px; margin-bottom: 4px; }
.public-lead-card .form-grid { margin-top: 14px; }
.public-lead-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Charts ---------- */
.chart-wrap { position: relative; width: 100%; min-width: 0; }
.chart-wrap canvas { display: block; width: 100%; height: auto; max-width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; }

.stat-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.stat-line:last-child { border-bottom: 0; }
.stat-line b { font-family: var(--font-serif); font-size: 17px; }

.list-clean { list-style: none; margin: 0; padding: 0; }
.list-clean li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.list-clean li:last-child { border-bottom: 0; }
.mini-muted { font-size: 11.5px; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-dash { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: relative; height: auto; padding: 12px 14px;
    flex-direction: column; gap: 10px; overflow: visible;
  }
  .brand span { display: none; }
  .nav { flex-direction: row; overflow-x: auto; padding-bottom: 4px; gap: 4px; }
  .nav-item { flex: none; width: auto; padding: 8px 10px; }
  .nav-item span { white-space: nowrap; }
  .sidebar-foot { margin-top: 0; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .admin-link { flex: 1 1 180px; }
  .role-switch { flex: 1 1 180px; }
  .demo-note { flex: 1 1 100%; }
  .topbar { padding: 12px 18px; }
  .view { padding: 18px 18px 40px; }
  .topbar-actions .btn-ghost { display: none; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar h1 { font-size: 20px; }
  .role-chip span { display: none; }
  .topbar { gap: 8px; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .info-grid { grid-template-columns: minmax(0, 1fr); }
  .public-lead-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .public-topbar .btn-ghost { display: inline-flex; }
  .login-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calendar-grid { gap: 3px; }
  .cal-day { min-height: 70px; padding: 3px; }
  .cal-ev { font-size: 9px; }
  .version { grid-template-columns: minmax(0, 1fr); }
  .version .v-actions { justify-content: flex-start; max-width: none; }
  .modal-body { padding: 14px; }
  .modal-head { padding: 13px 14px; }
}
@media (max-width: 460px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .login-grid { grid-template-columns: minmax(0, 1fr); }
  .view { padding: 14px 12px 32px; }
  .topbar { padding: 10px 12px; }
  .icon-btn { width: 38px; height: 38px; }
  .role-chip { padding-right: 5px; }
}
