:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f2f0eb;
  --text: #202020;
  --muted: #6d6b67;
  --line: #e8e3da;
  --line-strong: #d6d1c6;
  --accent: #e24a3b;
  --accent-soft: #fff1ef;
  --dark: #262626;
  --success: #177245;
  --success-soft: #ecfaf2;
  --warning: #9a5b06;
  --warning-soft: #fff4e4;
  --info: #2a5ea6;
  --info-soft: #eef4ff;
  --radius: 22px;
  --shadow: 0 18px 40px rgba(22, 22, 22, 0.07);
  --shadow-soft: 0 10px 24px rgba(22, 22, 22, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fbfbfa 0%, #f0efeb 100%);
}
button, select, textarea, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  display: grid;
  grid-template-columns: 290px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--accent), #ff7667);
  color: white;
  font-weight: 800;
  font-size: 20px;
}
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.sidebar-group-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 18px 0 10px;
}

.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-link {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 13px 16px;
  border-radius: 16px;
  transition: 160ms ease;
}
.nav-link:hover, .nav-link.active {
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.sidebar-card {
  margin-top: 24px;
  background: var(--dark);
  color: white;
  border-radius: 22px;
  padding: 18px;
}
.sidebar-card small, .sidebar-card p { color: rgba(255,255,255,0.76); }
.sidebar-card p { margin-bottom: 0; }

.main { padding: 28px; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.topbar h1 { margin: 0; font-size: 34px; }
.topbar p { margin: 8px 0 0; color: var(--muted); }
.top-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.role-picker-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
select, input, textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
}
textarea { width: 100%; resize: vertical; min-height: 120px; }
.primary, .ghost, .soft-btn, .status-btn, .big-action, .chip-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
}
.primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 14px 30px rgba(226, 74, 59, 0.22);
}
.ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
}
.soft-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.status-btn { background: var(--info-soft); color: var(--info); }
.block { width: 100%; }

#app-content { display: grid; gap: 18px; }

.grid-2, .grid-3, .grid-4, .grid-gantt {
  display: grid;
  gap: 18px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-gantt { grid-template-columns: 1.7fr 0.95fr; }

.card, .panel, .kpi-card, .kanban-column {
  background: var(--surface);
  border: 1px solid rgba(232,227,218,0.95);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.kpi-card { padding: 20px; }
.kpi-card span { display: block; color: var(--muted); font-size: 14px; }
.kpi-card strong { display: block; font-size: 34px; margin: 10px 0 4px; }
.kpi-card small { color: var(--muted); }
.panel { padding: 20px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h2, .panel-head h3 { margin: 0; font-size: 18px; }
.panel-head p { margin: 6px 0 0; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.inline-tags, .chips, .filter-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tag, .pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}
.badge.red, .pill.red { color: var(--accent); background: var(--accent-soft); border-color: rgba(226, 74, 59, 0.16); }
.badge.green { color: var(--success); background: var(--success-soft); border-color: rgba(23,114,69,0.12); }
.badge.orange { color: var(--warning); background: var(--warning-soft); border-color: rgba(154,91,6,0.12); }
.badge.blue { color: var(--info); background: var(--info-soft); border-color: rgba(42,94,166,0.12); }
.pill.active { background: var(--accent); color: white; border-color: transparent; }

.action-list, .stack, .metric-stack, .list-cards { display: grid; gap: 12px; }
.action-row, .metric-item, .mini-card, .reserve-card, .draft-card, .feed-row {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 18px;
  padding: 14px 16px;
}
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.action-row-main { display: grid; gap: 4px; }
.action-row strong { font-size: 15px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.metric-item { display: grid; gap: 6px; background: var(--surface); }
.metric-item span { color: var(--muted); font-size: 13px; }
.metric-item strong { font-size: 18px; }

.banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  border-radius: 24px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #fff5f3 0%, #ffe6e1 100%);
  border: 1px solid rgba(226, 74, 59, 0.16);
}
.banner-icon {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  font-size: 24px;
}
.banner strong { display: block; font-size: 18px; }
.banner p { margin: 4px 0 0; color: #854e47; }
.banner .primary { white-space: nowrap; }

.timeline {
  display: grid;
  gap: 12px;
}
.timeline-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.timeline-item:last-child { border-bottom: 0; }
.date-pill {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 700;
}

.gantt {
  display: grid;
  gap: 14px;
}
.gantt-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.swatch { width: 14px; height: 14px; border-radius: 999px; }
.swatch.done { background: #3f3f3f; }
.swatch.active { background: #f08f4c; }
.swatch.risk { background: var(--accent); }
.swatch.plan { background: #e8bdb6; }
.gantt-grid {
  display: grid;
  gap: 12px;
}
.gantt-head, .gantt-row {
  display: grid;
  grid-template-columns: 200px repeat(10, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}
.gantt-head { color: var(--muted); font-size: 13px; }
.gantt-row-title { display: grid; gap: 4px; }
.gantt-track {
  grid-column: 2 / span 10;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}
.gantt-bar {
  height: 22px;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(22,22,22,0.08);
}
.gantt-bar.done { background: linear-gradient(90deg, #2e2e2e, #555); }
.gantt-bar.active { background: linear-gradient(90deg, #f0b26a, #f08f4c); }
.gantt-bar.risk { background: linear-gradient(90deg, #ff8f7d, var(--accent)); }
.gantt-bar.plan { background: linear-gradient(90deg, #f3d2cc, #e7b5ac); }
.gantt-note { color: var(--muted); font-size: 12px; }

.side-context .metric-stack { margin-bottom: 16px; }
.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #ff7c6a); }

.upload-box {
  border: 1px dashed var(--line-strong);
  border-radius: 20px;
  background: var(--surface-2);
  padding: 18px;
}
.kbd-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
.dual-column {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 18px;
}
.draft-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.draft-cards { display: grid; gap: 12px; margin-top: 14px; }
.draft-card strong, .reserve-card strong, .mini-card strong { display: block; }
.draft-card span, .reserve-card span, .mini-card span { color: var(--muted); }

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.kanban-column { padding: 16px; }
.kanban-column h3 { margin: 0 0 12px; }
.kanban-count { color: var(--muted); font-size: 12px; margin-left: 8px; }
.reserve-card {
  background: white;
  box-shadow: var(--shadow-soft);
  display: grid;
  gap: 8px;
}
.reserve-card-top, .reserve-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.reserve-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.lot-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}
.segmented {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 10px 14px;
  border-radius: 999px;
}
.segmented button.active { background: white; box-shadow: var(--shadow-soft); }

.finance-table, .simple-table {
  width: 100%;
  border-collapse: collapse;
}
.finance-table th, .finance-table td, .simple-table th, .simple-table td {
  text-align: left;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.finance-table th, .simple-table th { color: var(--muted); font-size: 13px; font-weight: 600; }

.notice {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.notice.red { background: var(--accent-soft); border-color: rgba(226,74,59,0.16); }
.notice.green { background: var(--success-soft); border-color: rgba(23,114,69,0.14); }
.notice.blue { background: var(--info-soft); border-color: rgba(42,94,166,0.12); }

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.big-action {
  min-height: 94px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 700;
}
.big-action:hover { background: white; }

.callout {
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.value-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.value-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}
.value-card strong { display: block; font-size: 28px; margin-top: 8px; }

.audit-list { display: grid; gap: 10px; }
.feed-row { display: grid; gap: 4px; background: white; }
.feed-row small { color: var(--muted); }

.empty-state {
  text-align: center;
  padding: 28px 20px;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
  background: var(--surface-2);
}

@media (max-width: 1240px) {
  .grid-4, .grid-3, .grid-2, .grid-gantt, .dual-column, .lot-grid, .kanban, .action-grid { grid-template-columns: 1fr; }
  .gantt-head, .gantt-row { grid-template-columns: 1fr; }
  .gantt-track { grid-column: auto; }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .topbar { flex-direction: column; }
}
