/* Production polish — cards, tables, buttons, density */

body.proto {
  --radius-card: 16px;
  --radius-ctrl: 10px;
  --line: color-mix(in srgb, var(--md-sys-color-outline-variant) 80%, transparent);
  --shadow-card: 0 1px 2px rgba(18, 24, 38, 0.04), 0 8px 24px -12px rgba(18, 24, 38, 0.12);
  --shadow-hover: 0 2px 6px rgba(18, 24, 38, 0.06), 0 12px 28px -10px rgba(18, 24, 38, 0.16);
}

body.proto .wf-main {
  background: var(--md-sys-color-surface-container-low);
}
body.proto .wf-content {
  padding: 20px var(--gutter) 40px;
  background: transparent;
}
body.proto .wf-sidebar {
  background: var(--md-sys-color-surface-container-lowest);
  border-right: 1px solid var(--line);
}

/* ===== Page header ===== */
body.proto .wf-page-header {
  align-items: flex-end;
  margin: 0 0 20px;
  padding-bottom: 4px;
}
body.proto .wf-page-header h2 {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 500;
  letter-spacing: -0.02em;
}
body.proto .wf-crumbs {
  font-size: 12px;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
  text-transform: capitalize;
}
body.proto .wf-actions {
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ===== Buttons ===== */
body.proto .wf-btn,
body.proto a.wf-btn {
  cursor: pointer;
  border-radius: 999px;
  font-weight: 500;
  letter-spacing: 0.15px;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, filter 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: none;
}
body.proto .wf-btn.sm {
  min-height: 34px;
  padding: 0 14px;
  font-size: 13px;
}
body.proto .wf-btn.primary {
  box-shadow: 0 1px 2px rgba(0, 80, 80, 0.2);
}
body.proto .wf-btn.primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 2px 8px rgba(0, 80, 80, 0.28);
}
body.proto .wf-btn:not(.primary):not(.danger):hover {
  background: var(--md-sys-color-secondary-container);
}
body.proto .wf-btn.ghost {
  outline: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-lowest);
}
body.proto .wf-btn.ghost:hover {
  background: var(--md-sys-color-surface-container);
  outline-color: var(--md-sys-color-primary);
}
body.proto .wf-btn.danger:hover { filter: brightness(0.97); }
body.proto .wf-btn:active { transform: translateY(1px); }

/* ===== KPI / cards ===== */
body.proto .wf-grid { gap: 14px; }
body.proto .wf-two-col { gap: 16px; align-items: start; }

body.proto .wf-card-box,
body.proto .md-card-elevated.wf-card-box {
  position: relative;
  padding: 16px;
  border-radius: 12px;
  background: var(--md-sys-color-surface-container-lowest);
  box-shadow: var(--md-sys-elev-1);
  border: 0;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
body.proto .wf-grid > .wf-card-box:hover {
  box-shadow: var(--md-sys-elev-2);
  transform: none;
}
body.proto .wf-grid > .wf-card-box::before { display: none; }
body.proto .wf-card-box .label,
body.proto .md-card-kicker {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: none;
  color: var(--md-sys-color-on-surface-variant);
}
body.proto .wf-card-box .value,
body.proto .md-card-title {
  font-size: 24px;
  line-height: 32px;
  font-weight: 400;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}
body.proto .wf-card-box .hint,
body.proto .md-card-support {
  margin-top: 2px;
  font-size: 12px;
  line-height: 16px;
}

body.proto .wf-ai-box:not(.ai-decide) {
  border-radius: var(--radius-card);
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
  box-shadow: var(--shadow-card);
  line-height: 1.55;
}
body.proto .wf-ai-box:not(.ai-decide) .ai-tag {
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
}

/* ===== Tables ===== */
body.proto .wf-table-wrap {
  border-radius: var(--radius-card);
  background: var(--md-sys-color-surface-container-lowest);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--line);
  overflow: auto;
  max-width: 100%;
  margin-bottom: 20px;
}
body.proto .wf-card-box > .wf-table-wrap,
body.proto .wf-card-box .wf-table-wrap {
  box-shadow: none;
  margin-top: 12px;
  margin-bottom: 0;
}
body.proto .wf-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13.5px;
  line-height: 1.4;
}
body.proto .wf-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  text-align: left;
}
body.proto .wf-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--md-sys-color-on-surface);
}
body.proto .wf-table tbody tr:last-child td { border-bottom: 0; }
body.proto .wf-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--md-sys-color-surface-container) 45%, transparent);
}
body.proto .wf-table tbody tr.click-row {
  transition: background 0.12s ease;
}
body.proto .wf-table tbody tr.click-row:hover td {
  background: var(--md-sys-color-secondary-container);
}
body.proto .wf-table tr.highlight td {
  background: color-mix(in srgb, var(--md-sys-color-tertiary-container) 70%, #fff) !important;
}
body.proto .wf-table td.mono,
body.proto .wf-table td:first-child {
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--md-sys-color-on-surface-variant);
  white-space: nowrap;
}
body.proto .wf-table td:last-child {
  text-align: right;
  white-space: nowrap;
}
body.proto .wf-table td:last-child .wf-btn {
  margin-left: 6px;
  vertical-align: middle;
}
body.proto .wf-table td:last-child .wf-btn:first-child { margin-left: 0; }

/* Chip */
body.proto .wf-chip {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Banner / checklist / tabs */
body.proto .wf-banner {
  border-radius: 12px;
  margin-bottom: 16px;
  padding: 12px 16px;
  font-size: 13px;
}
body.proto .wf-check {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--line);
  border-bottom: 0;
  padding: 12px 14px;
  align-items: center;
  gap: 12px;
}
body.proto .wf-check:first-of-type { border-radius: 12px 12px 0 0; }
body.proto .wf-check:last-of-type {
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 12px 12px;
}
body.proto .wf-tabs {
  gap: 0;
  margin-bottom: 18px;
}
body.proto .wf-tab {
  padding: 12px 16px;
  text-decoration: none;
}

/* Kanban + flow */
body.proto .wf-col {
  background: var(--md-sys-color-surface-container);
  box-shadow: none;
  border: 1px solid var(--line);
  border-radius: 16px;
}
body.proto .wf-card-mini {
  box-shadow: var(--md-sys-elev-1);
  border: 0;
  border-radius: 12px;
  padding: 14px;
  transition: box-shadow 0.2s ease;
}
body.proto .wf-card-mini:hover {
  transform: none;
  box-shadow: var(--md-sys-elev-2);
}
body.proto .wf-card-mini .md-card-head { margin-bottom: 6px; }

body.proto .flow-step {
  border: 0;
  box-shadow: none;
  transition: box-shadow 0.2s ease, background 0.2s ease;
}
body.proto .flow-step:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  background: var(--md-sys-color-surface-container-lowest);
}

body.proto .wf-placeholder {
  border-style: solid;
  border-color: var(--line);
}

body.proto .wf-kv {
  gap: 10px 16px;
}
body.proto .wf-kv .v { font-weight: 500; }

/* Topbar polish */
body.proto .wf-topbar {
  background: var(--md-sys-color-surface-container-lowest);
  border-bottom: 1px solid var(--line);
}
body.proto .topbar-search,
body.proto .topbar-role,
body.proto .nav-toggle {
  border: 1px solid var(--line);
  background: var(--md-sys-color-surface);
}
body.proto .topbar-search:focus-within {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--md-sys-color-primary) 18%, transparent);
}

/* Login */
body.proto .wf-card {
  border: 1px solid rgba(255,255,255,0.08);
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin: 4px 0 20px;
}
.chart-card {
  background: var(--md-sys-color-surface-container-lowest);
  border: 0;
  border-radius: 12px;
  box-shadow: var(--md-sys-elev-1);
  padding: 16px 16px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.chart-card.is-wide { grid-column: 1 / -1; }
.chart-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex: 0 0 auto;
}
.chart-card-head h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1px;
  flex: 1;
  min-width: 0;
}
.chart-card-head .live-dot { margin-left: auto; }
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
  animation: pulse-dot 1.8s ease-out infinite;
}
@keyframes pulse-dot {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}
.chart-body {
  position: relative;
  width: 100%;
  height: 240px;
  max-height: 240px;
  flex: 0 0 240px;
  overflow: hidden;
}
.chart-card.is-wide .chart-body {
  height: 260px;
  max-height: 260px;
  flex: 0 0 260px;
}
.chart-body canvas {
  display: block;
  width: 100% !important;
  height: 240px !important;
  max-height: 240px !important;
}
.chart-card.is-wide .chart-body canvas {
  height: 260px !important;
  max-height: 260px !important;
}

@media (max-width: 900px) {
  .chart-grid { grid-template-columns: 1fr; }
}
  body.proto .wf-grid.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  body.proto .wf-grid.cols-2,
  body.proto .wf-grid.cols-3,
  body.proto .wf-grid.cols-4 { grid-template-columns: 1fr; }
}
