﻿/* admin.css — EtiketMarket Admin HTML versiyonu component stilleri.
   tokens.css'i extend eder. Import sırası: tokens.css → admin.css */

/* === Layout shell ====================================== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; position: sticky; top: 0;
  transition: width 200ms cubic-bezier(.3,.7,.4,1);
}
.sidebar.collapsed { width: 56px; }
.sidebar-logo {
  height: 56px; padding: 0 var(--sp-7);
  display: flex; align-items: center; gap: var(--sp-5);
  border-bottom: 1px solid var(--border-subtle);
}
.sidebar-logo .logo {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}
.sidebar.collapsed .sidebar-logo .brand { display: none; }
.sidebar-logo .brand .name { font-weight: 600; font-size: var(--text-md); color: var(--text-strong); letter-spacing: var(--tracking-tight); }
.sidebar-logo .brand .sub { font-size: var(--text-2xs); color: var(--text-muted); letter-spacing: var(--tracking-caps); text-transform: uppercase; font-weight: 500; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--sp-6) var(--sp-5); }
.nav-group { margin-bottom: var(--sp-7); }
.nav-group-title {
  padding: 0 var(--sp-6) var(--sp-3);
  font-size: var(--text-2xs); letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--text-subtle); font-weight: 600;
}
.sidebar.collapsed .nav-group-title { display: none; }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-5);
  width: 100%; padding: 7px var(--sp-6);
  background: transparent; color: var(--text-muted);
  border: 0; border-radius: var(--r-md);
  font-size: var(--text-base); font-weight: 400;
  cursor: pointer; text-align: left;
  text-decoration: none; position: relative;
  transition: background 80ms, color 80ms;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text-on-accent-soft); font-weight: 500; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 7px 0; }
.sidebar.collapsed .nav-item span:not(.nav-badge-dot) { display: none; }
.nav-item .label { flex: 1; }
.nav-badge {
  display: inline-flex; align-items: center; height: 18px;
  padding: 0 6px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-muted);
  font-size: var(--text-2xs); font-weight: 500;
}
.nav-item.active .nav-badge { background: var(--accent); color: white; }
.nav-badge.danger { background: var(--danger-soft); color: var(--danger); }
.nav-badge-dot {
  position: absolute; top: 4px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); display: none;
}
.sidebar.collapsed .nav-badge-dot { display: block; }
.sidebar.collapsed .nav-badge { display: none; }

.sidebar-foot {
  padding: var(--sp-6) var(--sp-7); border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: var(--sp-5);
}
.sidebar.collapsed .sidebar-foot { display: none; }
.env-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.env-dot.staging { background: oklch(70% 0.16 75); }
.env-dot.dev { background: var(--info); }

/* === Topbar ============================================ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: 56px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px) saturate(180%);
  -webkit-backdrop-filter: blur(12px) saturate(180%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-6);
  padding: 0 var(--sp-9);
}
.topbar-search { flex: 0 1 480px; }
.topbar-spacer { flex: 1; }
.role-pill {
  display: inline-flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-5); height: 32px;
  background: var(--surface-3); border-radius: var(--r-md);
  font-size: var(--text-xs);
}
.role-pill select {
  appearance: none; background: transparent; border: 0; padding: 0;
  font-size: var(--text-sm); font-weight: 500; color: var(--text); cursor: pointer;
  outline: none;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { flex: 1; min-width: 0; }

/* === Buttons =========================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-3);
  height: var(--control-h); padding: 0 var(--sp-7);
  border-radius: var(--r-md); font-weight: 500;
  font-size: var(--text-base); letter-spacing: var(--tracking-tight);
  border: 1px solid transparent; cursor: pointer;
  white-space: nowrap;
  transition: background 80ms, border-color 80ms, color 80ms;
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong); box-shadow: var(--shadow-xs);
  text-decoration: none;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { background: var(--surface-active); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.btn-primary { background: var(--accent); color: white; border-color: transparent; box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 1px 2px rgba(15,23,42,0.12); }
.btn.btn-primary:hover { background: var(--accent-hover); }
.btn.btn-primary:active { background: var(--accent-active); }
.btn.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text); }
.btn.btn-ghost:hover { background: var(--surface-hover); }
.btn.btn-ghost-muted { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-muted); }
.btn.btn-ghost-muted:hover { background: var(--surface-hover); color: var(--text); }
.btn.btn-danger { background: var(--danger); color: white; border-color: transparent; }
.btn.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--border-strong); }
.btn.btn-danger-outline:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.btn-sm { height: var(--control-h-sm); padding: 0 var(--sp-6); font-size: var(--text-sm); }
.btn.btn-lg { height: var(--control-h-lg); padding: 0 var(--sp-9); font-size: var(--text-md); }
.btn.btn-icon { width: var(--control-h); padding: 0; }
.btn.btn-icon.btn-sm { width: var(--control-h-sm); height: var(--control-h-sm); padding: 0; }
.btn .svg-ico { width: 14px; height: 14px; flex-shrink: 0; }
.btn-block { width: 100%; }

/* === Badge ============================================= */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 22px; padding: 0 var(--sp-5);
  border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 500;
  letter-spacing: var(--tracking-tight);
  border: 1px solid transparent;
  white-space: nowrap;
  background: var(--neutral-soft); color: var(--text-muted);
}
.badge.tone-accent  { background: var(--accent-soft);  color: var(--text-on-accent-soft); }
.badge.tone-success { background: var(--success-soft); color: var(--success); }
.badge.tone-warn    { background: var(--warn-soft);    color: oklch(45% 0.14 75); }
.badge.tone-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge.tone-info    { background: var(--info-soft);    color: var(--info); }
.badge.size-xs      { height: 18px; padding: 0 var(--sp-4); font-size: var(--text-2xs); }
.badge .dot         { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
[data-theme='dark'] .badge.tone-warn { color: oklch(80% 0.15 75); }
[data-theme='dark'] .badge.tone-success { color: oklch(78% 0.16 152); }
[data-theme='dark'] .badge.tone-danger { color: oklch(75% 0.18 25); }
[data-theme='dark'] .badge.tone-info { color: oklch(78% 0.13 220); }

/* === Input ============================================= */
.input-wrap {
  display: inline-flex; align-items: center; gap: var(--sp-4);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  height: var(--control-h); padding: 0 var(--sp-6);
  color: var(--text);
  transition: border-color 80ms, box-shadow 80ms;
}
.input-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus-ring); }
.input-wrap.full { display: flex; width: 100%; }
.input-wrap.flush { border-color: transparent; background: transparent; }
.input-wrap.flush:hover { background: var(--surface-hover); }
.input-wrap.flush:focus-within { background: var(--surface); border-color: var(--accent); }
.input-wrap.lg { height: var(--control-h-lg); }
.input-wrap .svg-ico { color: var(--text-subtle); flex-shrink: 0; width: 14px; height: 14px; }
.input-wrap input, .input-wrap select, .input-wrap textarea {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: none;
  height: 100%; padding: 0; color: var(--text); font: inherit;
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
}
/* Textarea içinde sabit 32px yükseklik kırılır — wrap büyüsün */
.input-wrap:has(> textarea) {
  height: auto;
  min-height: var(--control-h);
  align-items: flex-start;
  padding: var(--sp-4) var(--sp-6);
}
.input-wrap > textarea {
  height: auto !important;
  min-height: 72px;
  padding: var(--sp-2) 0;
  line-height: 1.45;
  resize: vertical;
}
.input-wrap select {
  /* native arrow hidden so the explicit chevron SVG we append doesn't double up */
  background-image: none;
  cursor: pointer;
}
.input-wrap select::-ms-expand { display: none; }
.input-wrap select[multiple] {
  /* multi-selects need their natural height — don't try to squeeze them into the 32px row */
  appearance: auto; -webkit-appearance: auto; -moz-appearance: auto;
  height: auto; min-height: 80px;
}
/* Pseudo-chevron eklendiğinde select textinin chevron'un altına gelmemesi için sağ padding */
.input-wrap:has(> select:not([multiple])):not(:has(> select ~ .svg-ico)) > select {
  padding-right: var(--sp-7);
}
/* Select2 etkinse pseudo-chevron çıkmasın (Select2 kendi okunu çizer) */
.input-wrap.has-select2::after { content: none !important; }

/* Native <select> içeren her .input-wrap'a otomatik sistem chevron'ı ekle.
   Böylece view'larda manuel @EmIcons.Svg("chevronDown") yazılmasa bile
   görsel olarak Select2 ve text input ile pixel-perfect aynı görünür.
   `:has()` modern tarayıcılarda desteklenir; fallback olarak native chevron
   appearance:none ile zaten gizlenmiş, en kötü senaryoda chevronsuz görünür.
   Eğer view zaten select'in ardından manuel bir .svg-ico (chevronDown) eklediyse
   pseudo-element çıkmaz; çift chevron'u önler. */
.input-wrap:has(> select:not([multiple])) {
  position: relative;
}
.input-wrap:has(> select:not([multiple])):not(:has(> select ~ .svg-ico))::after {
  content: '';
  position: absolute;
  right: var(--sp-5);
  top: 50%;
  width: 12px;
  height: 12px;
  pointer-events: none;
  transform: translateY(-50%);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.85;
  transition: opacity 80ms ease;
}
.input-wrap:has(> select:not([multiple])):not(:has(> select ~ .svg-ico)):focus-within::after {
  opacity: 1;
}
/* multiple select için chevron gerekmez (yükseklik zaten farklı, native UI kullanılır) */
[data-theme='dark'] .input-wrap:has(> select:not([multiple])):not(:has(> select ~ .svg-ico))::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23a3aab8' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* === Chip group (multi-select alternative) ================================ */
.chip-group {
  display: flex; flex-wrap: wrap; gap: var(--sp-3);
  padding: 4px 0;
}
.chip-opt {
  display: inline-flex; align-items: center; gap: 0;
  padding: 5px 12px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-muted); font-size: var(--text-sm); font-weight: 500;
  cursor: pointer; user-select: none;
  transition: background 80ms, border-color 80ms, color 80ms;
}
.chip-opt:hover { background: var(--surface-hover); color: var(--text); }
.chip-opt input { display: none; }
.chip-opt.on {
  background: var(--accent-soft); border-color: var(--accent);
  color: var(--text-on-accent-soft);
}
.chip-opt.on::before {
  content: ''; width: 12px; height: 12px; margin-right: 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%233858E9' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><path d='M20 6 9 17l-5-5'/></svg>");
  background-size: contain; background-repeat: no-repeat;
}
.input-wrap input::placeholder { color: var(--text-subtle); }
.input-wrap.error { border-color: var(--danger); }
.input-wrap.error:focus-within { box-shadow: 0 0 0 3px oklch(70% 0.18 25 / 0.3); }
.input-wrap .kbd {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: var(--text-2xs); color: var(--text-subtle);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--r-xs); padding: 1px 5px;
  font-family: var(--font-mono);
}
/* Sistem geneli: bare + .textarea — input/select ile aynı yüzey dili */
.field > textarea,
textarea.textarea,
textarea:not([class*="tox"]):not(.cm-json) {
  width: 100%;
  min-height: 88px;
  padding: var(--sp-5) var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  resize: vertical;
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  outline: none;
  line-height: 1.45;
  box-sizing: border-box;
  transition: border-color 80ms, box-shadow 80ms;
}
.field > textarea:focus,
textarea.textarea:focus,
textarea:not([class*="tox"]):not(.cm-json):focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.field > textarea::placeholder,
textarea.textarea::placeholder,
textarea:not([class*="tox"]):not(.cm-json)::placeholder {
  color: var(--text-subtle);
}
/* input-wrap içindeki textarea'lar zaten border'sız; çift çerçeve olmasın */
.input-wrap > textarea,
.input-wrap > textarea:focus {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  padding-left: 0;
  padding-right: 0;
  min-height: 72px;
}

/* === Field (form) ====================================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: var(--text-sm); color: var(--text); font-weight: 500;
}
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-help { font-size: var(--text-xs); color: var(--text-muted); }
.field-error { font-size: var(--text-xs); color: var(--danger); display: flex; align-items: center; gap: 4px; }

.form-grid { display: grid; gap: var(--sp-7); }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
.form-section { padding: var(--sp-10) var(--sp-11); border-bottom: 1px solid var(--border); }
.form-section:last-child { border-bottom: 0; }
.form-section-hd {
  display: grid; grid-template-columns: 240px 1fr; gap: var(--sp-11);
  margin-bottom: var(--sp-8);
}
.form-section-hd h3 { margin: 0 0 4px; font-size: var(--text-md); font-weight: 600; color: var(--text-strong); }
.form-section-hd p { margin: 0; font-size: var(--text-sm); color: var(--text-muted); line-height: var(--leading-snug); }
.form-section-body { display: grid; grid-template-columns: 240px 1fr; gap: var(--sp-11); }
.form-section-body > div:nth-child(2) { display: flex; flex-direction: column; gap: var(--sp-7); }

/* Checkbox + radio + toggle */
.check {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-xs);
  cursor: pointer;
  position: relative;
  transition: background 80ms, border-color 80ms;
}
.check:hover { border-color: var(--accent); }
.check:checked { background: var(--accent); border-color: var(--accent); }
.check:checked::after {
  content: ''; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px; border: solid white;
  border-width: 0 1.8px 1.8px 0; transform: rotate(45deg);
}
.check-label {
  display: inline-flex; align-items: center; gap: var(--sp-4);
  font-size: var(--text-sm); color: var(--text); cursor: pointer; user-select: none;
}
.toggle {
  position: relative; width: 32px; height: 18px;
  border: 0; border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer; padding: 0;
  transition: background 120ms;
}
.toggle.on { background: var(--accent); }
.toggle i {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: white; transition: transform 120ms;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.toggle.on i { transform: translateX(14px); }

.seg {
  display: inline-flex; padding: 3px; background: var(--surface-3);
  border-radius: var(--r-md); gap: 2px;
}
.seg button {
  background: transparent; border: 0; padding: 5px 12px;
  font: inherit; font-size: var(--text-sm); color: var(--text-muted); cursor: pointer;
  border-radius: var(--r-sm); font-weight: 500;
}
.seg button.active {
  background: var(--surface); color: var(--text-strong); box-shadow: var(--shadow-xs);
}

/* === Card ============================================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6);
  padding: var(--sp-8) var(--sp-9);
  border-bottom: 1px solid var(--border-subtle);
}
.card-hd h3 { margin: 0; font-size: var(--text-md); font-weight: 600; letter-spacing: var(--tracking-tight); color: var(--text-strong); }
.card-hd .sub { color: var(--text-muted); font-size: var(--text-sm); margin-top: 2px; }
.card-hd .actions { display: flex; gap: var(--sp-4); }
.card-body { padding: var(--sp-9); }
.card-body.flush { padding: 0; }
.card-foot { padding: var(--sp-6) var(--sp-9); border-top: 1px solid var(--border-subtle); background: var(--surface-2); display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-4); }

/* === Table ============================================= */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-base); }
.table thead th {
  text-align: left; font-weight: 500;
  font-size: var(--text-xs); letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--text-subtle);
  background: var(--surface-2);
  padding: var(--sp-5) var(--sp-7);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: 0 var(--sp-7);
  height: var(--row-h);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:hover td { background: var(--surface-hover); }
.table tbody tr.selected td { background: var(--accent-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: var(--sp-9); }
.table th:last-child,  .table td:last-child  { padding-right: var(--sp-9); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.muted { color: var(--text-muted); }
.table tbody tr.clickable { cursor: pointer; }
.table-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: var(--sp-6) var(--sp-9); border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm); color: var(--text-muted);
}

/* === Toolbar =========================================== */
.toolbar {
  display: flex; align-items: center; gap: var(--sp-5);
  padding: var(--sp-6) var(--sp-9);
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg);
  flex-wrap: wrap;
}
.toolbar + .table-wrap { border-top-left-radius: 0; border-top-right-radius: 0; border-top: 0; }
.toolbar-spacer { flex: 1; }
.toolbar .count { font-size: var(--text-sm); color: var(--text-muted); }

/* === Page head ========================================= */
.pagehead {
  position: sticky; top: 56px; z-index: 9;
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-8);
  padding: var(--sp-8) var(--sp-11) var(--sp-7);
  background: var(--bg);
  border-bottom: 1px solid transparent;
  transition: padding 160ms ease, border-color 160ms ease, backdrop-filter 160ms ease;
}
.pagehead.is-stuck {
  padding: var(--sp-5) var(--sp-11);
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom-color: var(--border-subtle);
  box-shadow: 0 1px 0 var(--border-subtle);
}
.pagehead.is-stuck .breadcrumb,
.pagehead.is-stuck .sub { display: none; }
.pagehead.is-stuck h1 {
  font-size: var(--text-lg);
}
.pagehead h1 {
  margin: 0; font-size: var(--text-2xl); font-weight: 600;
  letter-spacing: var(--tracking-tight); color: var(--text-strong);
  transition: font-size 160ms ease;
}
.pagehead .sub { margin-top: 4px; font-size: var(--text-sm); color: var(--text-muted); }
.pagehead .actions { display: flex; gap: var(--sp-5); align-items: center; flex-wrap: wrap; }
.pagebody { padding: var(--sp-6) var(--sp-11) var(--sp-12); }
.breadcrumb { display: flex; gap: var(--sp-3); align-items: center; font-size: var(--text-sm); color: var(--text-muted); margin-bottom: var(--sp-4); }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb .svg-ico { width: 12px; height: 12px; }

/* === Tabs ============================================== */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); }
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-6) var(--sp-7);
  font-size: var(--text-base); font-weight: 500;
  color: var(--text-muted); background: transparent; border: 0;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text-strong); border-bottom-color: var(--accent); }
.tab .tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; padding: 0 5px; height: 18px;
  background: var(--surface-3); color: var(--text-muted);
  border-radius: var(--r-full); font-size: var(--text-2xs); font-weight: 500;
}
.tab.active .tab-count { background: var(--accent-soft); color: var(--text-on-accent-soft); }

/* === Avatar ============================================ */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--text-on-accent-soft);
  font-size: var(--text-2xs); font-weight: 600;
  flex-shrink: 0; border: 1px solid var(--surface);
}
.avatar.md { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar.lg { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar.xl { width: 56px; height: 56px; font-size: var(--text-md); }

/* === KPI =============================================== */
.kpi {
  display: flex; flex-direction: column; gap: var(--sp-3);
  padding: var(--sp-9);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.kpi .kpi-label {
  font-size: var(--text-sm); color: var(--text-muted); font-weight: 500;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
}
.kpi .kpi-value {
  font-size: var(--text-3xl); font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.kpi .kpi-delta {
  font-size: var(--text-sm);
  display: flex; align-items: center; gap: var(--sp-2);
}
.kpi .kpi-delta.up   { color: var(--success); }
.kpi .kpi-delta.down { color: var(--danger); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-8); margin-bottom: var(--sp-8); }

/* === Empty & loading =================================== */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--sp-14) var(--sp-9);
  text-align: center; color: var(--text-muted);
}
.empty .ico {
  width: 48px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-subtle);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-7);
}
.empty h4 { margin: 0 0 var(--sp-3) 0; font-size: var(--text-md); font-weight: 600; color: var(--text); letter-spacing: var(--tracking-tight); }
.empty p { margin: 0; max-width: 380px; font-size: var(--text-sm); line-height: var(--leading-snug); }
.empty .actions { margin-top: var(--sp-8); display: flex; gap: var(--sp-5); }

@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skel {
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-hover) 50%, var(--surface-3) 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: var(--r-sm); display: inline-block;
}

/* === Modal — modern, Linear/Notion paterni ===================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(ellipse at center,
    color-mix(in oklab, #0f172a 30%, transparent) 0%,
    color-mix(in oklab, #0f172a 55%, transparent) 100%);
  backdrop-filter: saturate(140%) blur(8px); -webkit-backdrop-filter: saturate(140%) blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-10);
  opacity: 0; pointer-events: none;
  transition: opacity 180ms ease;
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-xl);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 24px 48px -12px rgba(15, 23, 42, 0.35),
    0 8px 16px -6px rgba(15, 23, 42, 0.18);
  width: 100%; max-width: 520px; max-height: min(90vh, 800px);
  display: flex; flex-direction: column;
  transform: scale(0.96) translateY(12px);
  opacity: 0;
  transition: transform 220ms cubic-bezier(.16,.84,.44,1), opacity 180ms ease;
  overflow: hidden;
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); opacity: 1; }

.modal.modal-sm { max-width: 420px; }
.modal.modal-md { max-width: 560px; }
.modal.modal-lg { max-width: 760px; }
.modal.modal-xl { max-width: 1040px; }

/* Modal — header */
.modal-hd {
  position: relative;
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-7);
  padding: var(--sp-9) var(--sp-9) var(--sp-7);
}
.modal-hd > div:first-child { flex: 1; min-width: 0; }
.modal-hd h3 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-strong);
  letter-spacing: var(--tracking-tight);
  line-height: 1.2;
}
.modal-hd .sub {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}
/* Optional icon area in header */
.modal-hd .modal-icon {
  width: 40px; height: 40px;
  flex-shrink: 0;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  margin-right: var(--sp-2);
}
.modal-hd.with-icon { align-items: center; }

/* Modal — close button */
.modal-x {
  background: transparent;
  border: 0;
  width: 32px; height: 32px;
  margin: -4px -4px 0 0; /* visually align with title baseline */
  flex-shrink: 0;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 120ms ease, color 120ms ease, transform 120ms ease;
}
.modal-x:hover {
  background: var(--surface-hover);
  color: var(--text-strong);
}
.modal-x:active { transform: scale(0.94); }
.modal-x:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Modal — body */
.modal-body {
  padding: var(--sp-3) var(--sp-9) var(--sp-9);
  overflow-y: auto;
  flex: 1;
  scrollbar-gutter: stable;
}
.modal-body::-webkit-scrollbar { width: 6px; }
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 3px;
}

/* Modal — footer */
.modal-foot {
  padding: var(--sp-6) var(--sp-9);
  background: var(--surface-2);
  border-top: 1px solid var(--border-subtle);
  display: flex; align-items: center; gap: var(--sp-4);
  justify-content: flex-end;
  flex-wrap: wrap;
}
/* Danger button automatically pushed to the left in the footer */
.modal-foot > .btn-danger,
.modal-foot > .btn-danger-outline,
.modal-foot > .btn-danger-soft {
  margin-right: auto;
}

/* Modal — scroll-aware shadows on header/footer when body is scrolled */
.modal.is-scrolled-top .modal-hd {
  box-shadow: 0 1px 0 var(--border-subtle);
}
.modal.is-scrolled-bottom .modal-foot {
  box-shadow: 0 -1px 0 var(--border-subtle);
}

/* When form is the modal body wrapper */
form.modal-body { display: flex; flex-direction: column; gap: var(--sp-6); }
form.modal-body > .modal-foot {
  margin: var(--sp-3) calc(var(--sp-9) * -1) calc(var(--sp-9) * -1);
  padding-left: var(--sp-9); padding-right: var(--sp-9);
}

/* Dark theme — refine backdrop and border */
[data-theme="dark"] .modal-backdrop {
  background: radial-gradient(ellipse at center,
    rgba(0, 0, 0, 0.55) 0%,
    rgba(0, 0, 0, 0.75) 100%);
}
[data-theme="dark"] .modal {
  border-color: color-mix(in oklab, var(--border-strong) 60%, transparent);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.04) inset,
    0 28px 56px -12px rgba(0, 0, 0, 0.55),
    0 8px 20px -6px rgba(0, 0, 0, 0.4);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal { transition: opacity 0ms; }
  .modal { transform: none; }
}

/* === Toast ============================================= */
.toasts {
  position: fixed; top: var(--sp-9); right: var(--sp-9);
  z-index: 200; display: flex; flex-direction: column; gap: var(--sp-5);
  pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: var(--sp-6) var(--sp-7);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: var(--sp-5);
  min-width: 280px; max-width: 400px;
  pointer-events: auto;
  animation: toast-in 220ms cubic-bezier(.3,.7,.4,1);
}
@keyframes toast-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast .ico {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--success-soft); color: var(--success);
}
.toast.error .ico { background: var(--danger-soft); color: var(--danger); }
.toast.warn .ico { background: var(--warn-soft); color: oklch(50% 0.14 75); }
.toast.info .ico { background: var(--info-soft); color: var(--info); }
.toast .title { font-weight: 500; color: var(--text-strong); font-size: var(--text-sm); }
.toast .body { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; line-height: var(--leading-snug); }

/* === Dropdown menu ===================================== */
.menu {
  position: absolute; z-index: 60;
  min-width: 180px; padding: var(--sp-3);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
}
.menu-item {
  display: flex; align-items: center; gap: var(--sp-5);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-sm); font-size: var(--text-base); color: var(--text);
  cursor: pointer; user-select: none; text-decoration: none;
}
.menu-item:hover { background: var(--surface-hover); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-sep { height: 1px; margin: var(--sp-3) 0; background: var(--divider); }
.menu-section {
  padding: var(--sp-4) var(--sp-5) var(--sp-2);
  font-size: var(--text-2xs); letter-spacing: var(--tracking-caps);
  text-transform: uppercase; color: var(--text-subtle); font-weight: 500;
}

/* === Stepper =========================================== */
.stepper {
  display: flex; align-items: center; gap: 0;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 var(--sp-11);
}
.step {
  flex: 1; padding: var(--sp-7) 0;
  display: flex; align-items: center; gap: var(--sp-5);
  color: var(--text-muted); font-size: var(--text-sm);
  position: relative;
}
.step .step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-muted);
  font-size: var(--text-xs); font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.step.active { color: var(--text-strong); }
.step.active .step-num { background: var(--accent); color: white; }
.step.done { color: var(--success); }
.step.done .step-num { background: var(--success); color: white; }
.step .step-label { font-weight: 500; }
.step .step-sub { font-size: var(--text-xs); color: var(--text-subtle); margin-top: 2px; }
.step .step-text { display: flex; flex-direction: column; line-height: 1.2; }
.step::after {
  content: ''; position: absolute; top: 50%; right: 0;
  width: 24px; height: 1px; background: var(--border);
  transform: translateY(-50%);
}
.step:last-child::after { display: none; }

/* === Timeline ========================================== */
.timeline { position: relative; }
.timeline::before {
  content: ''; position: absolute;
  left: 13px; top: 14px; bottom: 14px;
  width: 1px; background: var(--border);
}
.tl-item { display: flex; gap: var(--sp-6); padding-bottom: var(--sp-7); }
.tl-bullet {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; z-index: 1; border: 2px solid var(--surface);
}
.tl-bullet.success { background: var(--success-soft); color: var(--success); }
.tl-bullet.warn { background: var(--warn-soft); color: oklch(50% 0.14 75); }
.tl-bullet.info { background: var(--info-soft); color: var(--info); }
.tl-bullet.accent { background: var(--accent-soft); color: var(--accent); }
.tl-body { flex: 1; padding-top: 4px; }
.tl-body .who { color: var(--text-strong); font-weight: 500; font-size: var(--text-sm); }
.tl-body .text { color: var(--text-muted); font-size: var(--text-sm); }
.tl-body .when { font-size: var(--text-xs); color: var(--text-subtle); margin-top: 2px; }

/* === Helpers =========================================== */
.row-h { display: flex; align-items: center; gap: var(--sp-5); }
.col-v { display: flex; flex-direction: column; }
.gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); } .gap-7 { gap: var(--sp-7); } .gap-8 { gap: var(--sp-8); }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.strong { color: var(--text-strong); font-weight: 500; }
.kv-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-row .k,
.kv-row > .muted:first-child {
  color: var(--text-muted);
  flex: 0 0 38%;
  max-width: 160px;
  font-weight: 500;
}
.kv-row .v,
.kv-row > .strong,
.kv-row > span:last-child {
  flex: 1;
  text-align: right;
  color: var(--text-strong);
  word-break: break-word;
}
.kv-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.kv-block .k {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 8px;
}
.kv-block .v {
  white-space: pre-wrap;
  line-height: 1.55;
  color: var(--text);
  font-size: var(--text-sm);
}
.flex-1 { flex: 1; min-width: 0; }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-4 { margin-top: var(--sp-8); } .mt-6 { margin-top: var(--sp-9); } .mt-8 { margin-top: var(--sp-11); }
.mb-4 { margin-bottom: var(--sp-8); }

/* Grid cards */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--sp-8); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-8); }

/* === Kanban ============================================ */
.kanban { display: grid; gap: var(--sp-6); overflow-x: auto; padding: 0 var(--sp-11) var(--sp-12); }
.kan-col { min-width: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-5); }
.kan-col-hd { display: flex; align-items: center; gap: var(--sp-4); }
.kan-col-title { font-weight: 600; font-size: var(--text-sm); color: var(--text-strong); }
.kan-card { cursor: grab; }
