/* =========================================================
   CutFlow · base tokens / reset / primitives
   ========================================================= */
:root {
  color-scheme: light;
  --font-ui: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;

  --bg: #f2f5f7;
  --bg-soft: #eef2f5;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eff4f6;
  --surface-inv: #121a22;
  --line: #e4eaee;
  --line-strong: #d5dfe5;
  --text: #111a22;
  --text-2: #596875;
  --text-3: #93a0aa;
  --text-inv: #f5fbfa;

  --primary: #0fae93;
  --primary-2: #18c4a6;
  --primary-deep: #07836f;
  --primary-soft: #e4f8f3;
  --primary-soft-2: #d4f4ec;
  --primary-ink: #087a68;

  --violet: #8b6cf0;
  --violet-2: #a58cf7;
  --violet-soft: #f0ecff;
  --violet-ink: #6244d8;

  --amber: #e9a13a;
  --amber-soft: #fff4e2;
  --danger: #e95c60;
  --danger-soft: #ffedee;
  --blue: #4e8ee8;
  --blue-soft: #eaf2ff;

  --radius-xl: 18px;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-xs: 6px;

  --shadow-sm: 0 1px 2px rgba(18, 32, 43, .04), 0 6px 18px -14px rgba(18, 32, 43, .3);
  --shadow-md: 0 2px 4px rgba(18, 32, 43, .04), 0 18px 40px -26px rgba(18, 32, 43, .38);
  --shadow-lg: 0 4px 8px rgba(18, 32, 43, .05), 0 28px 64px -30px rgba(18, 32, 43, .42);
  --shadow-primary: 0 10px 24px -12px rgba(15, 174, 147, .55);
  --shadow-violet: 0 10px 24px -12px rgba(139, 108, 240, .55);

  --topbar-h: 56px;
  --sidebar-w: 220px;
  --main-max: 1460px;
  --ease: cubic-bezier(.22, .68, .26, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);

  --grid-line: rgba(17, 26, 34, .045);
}

html[data-theme="night"] {
  color-scheme: dark;
  --bg: #0f1218;
  --bg-soft: #0c1015;
  --surface: #171c25;
  --surface-2: #1a202c;
  --surface-3: #202836;
  --surface-inv: #e9eff6;
  --line: #27303f;
  --line-strong: #344051;
  --text: #e8edf5;
  --text-2: #9aa6b4;
  --text-3: #657181;
  --text-inv: #10161e;

  --primary: #22c599;
  --primary-2: #3ad9b0;
  --primary-deep: #169d79;
  --primary-soft: rgba(34, 197, 153, .12);
  --primary-soft-2: rgba(34, 197, 153, .19);
  --primary-ink: #72e3c4;

  --violet: #9b82f5;
  --violet-2: #b19cf9;
  --violet-soft: rgba(155, 130, 245, .14);
  --violet-ink: #c4b5ff;

  --amber: #efb25a;
  --amber-soft: rgba(239, 178, 90, .12);
  --danger: #f06a6d;
  --danger-soft: rgba(240, 106, 109, .12);
  --blue: #6ea3f0;
  --blue-soft: rgba(110, 163, 240, .13);

  --shadow-sm: 0 1px 1px rgba(0, 0, 0, .2), 0 10px 24px -20px #000;
  --shadow-md: 0 2px 4px rgba(0, 0, 0, .2), 0 22px 44px -28px #000;
  --shadow-lg: 0 4px 10px rgba(0, 0, 0, .24), 0 34px 70px -34px #000;
  --shadow-primary: 0 10px 28px -12px rgba(34, 197, 153, .38);
  --shadow-violet: 0 10px 28px -12px rgba(155, 130, 245, .4);

  --grid-line: rgba(232, 237, 245, .035);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 76px 76px;
  mask-image: radial-gradient(ellipse 90% 70% at 60% 0%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 60% 0%, #000 0%, transparent 78%);
}
body.is-booting { overflow: hidden; }

[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
h1, h2, h3, h4, p { margin: 0; }
kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  padding: 4px 5px;
  border: 1px solid currentColor;
  border-radius: 4px;
  opacity: .65;
}
code { font-family: var(--font-mono); font-size: .92em; padding: 1px 4px; border-radius: 4px; background: var(--surface-3); color: var(--text-2); }
::selection { background: var(--primary-soft-2); color: var(--text); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.icon { width: 18px; height: 18px; flex: 0 0 auto; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }
.icon-xl { width: 28px; height: 28px; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border: 3px solid transparent; background-clip: content-box; border-radius: 10px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* =========================================================
   Buttons
   ========================================================= */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 15px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -.01em;
  white-space: nowrap;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s, border-color .18s, color .18s, opacity .18s;
}
.btn .icon { width: 16px; height: 16px; }
.btn:hover { transform: translateY(-1px); border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary { --btn-bg: var(--primary); --btn-fg: #fff; --btn-bd: transparent; box-shadow: var(--shadow-primary); }
.btn-primary:hover { --btn-bg: var(--primary-2); box-shadow: 0 14px 30px -12px rgba(15, 174, 147, .55); }
.btn-violet { --btn-bg: linear-gradient(120deg, var(--violet) 0%, #9f7df6 100%); --btn-fg: #fff; --btn-bd: transparent; box-shadow: var(--shadow-violet); }
.btn-violet:hover { filter: brightness(1.05) saturate(1.04); }
.btn-soft { --btn-bg: var(--primary-soft); --btn-fg: var(--primary-ink); --btn-bd: transparent; }
.btn-soft:hover { --btn-bg: var(--primary-soft-2); }
.btn-ghost { --btn-bg: transparent; --btn-bd: var(--line); }
.btn-ghost:hover { --btn-bg: var(--surface-2); }
.btn-danger { --btn-bg: var(--danger-soft); --btn-fg: var(--danger); --btn-bd: transparent; }
.btn-lg { height: 46px; padding: 0 20px; border-radius: 10px; font-size: 13.5px; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 12px; border-radius: 7px; gap: 5px; }
.btn-block { width: 100%; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading .icon { animation: spin .9s linear infinite; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-2);
  transition: background .18s, color .18s, transform .18s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(.96); }
.icon-btn.is-active { background: var(--primary-soft); color: var(--primary-ink); }
.icon-btn .icon { width: 19px; height: 19px; }

.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 550;
  border-radius: 6px;
  padding: 4px 6px;
  transition: color .18s, background .18s;
}
.text-btn:hover { color: var(--primary-ink); background: var(--primary-soft); }

/* =========================================================
   Inputs
   ========================================================= */
.input, .textarea, .select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .textarea:hover { border-color: var(--line-strong); }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { height: auto; min-height: 90px; padding: 11px 12px; resize: vertical; line-height: 1.65; }
.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 17px; height: 17px; pointer-events: none; }
.input-wrap .input { padding-left: 37px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; font-weight: 650; color: var(--text); }
.field-hint { color: var(--text-3); font-size: 11.5px; line-height: 1.55; }
.field-hint.is-error { color: var(--danger); }
.required { color: var(--danger); font-weight: 600; }

/* Checkbox */
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.check-box {
  position: relative;
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  margin-top: 1px;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface);
  transition: background .16s, border-color .16s, box-shadow .16s;
}
.check-box::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 1.8px 1.8px 0;
  transform: rotate(42deg) scale(.4);
  opacity: 0;
  transition: transform .16s var(--ease-out), opacity .12s;
}
.check input:checked + .check-box { background: var(--primary); border-color: var(--primary); }
.check input:checked + .check-box::after { opacity: 1; transform: rotate(42deg) scale(1); }
.check input:focus-visible + .check-box { box-shadow: 0 0 0 3px var(--primary-soft); }
.check-text { font-size: 12.5px; color: var(--text-2); line-height: 1.45; }
.check-text strong { display: block; color: var(--text); font-weight: 600; font-size: 12.5px; }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 38px; height: 22px; border-radius: 20px; background: var(--line-strong); position: relative; transition: background .2s; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: transform .2s var(--ease-out); }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }

/* =========================================================
   Surfaces / common bits
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px 14px; }
.panel-head h2, .panel-head h3 { font-size: 15px; font-weight: 650; letter-spacing: -.02em; }
.panel-head p { margin-top: 3px; font-size: 12px; color: var(--text-3); }
.panel-body { padding: 0 20px 20px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; }
.badge-primary { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); }
.badge-violet { background: var(--violet-soft); border-color: transparent; color: var(--violet-ink); }
.badge-amber { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.badge-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.badge-blue { background: var(--blue-soft); border-color: transparent; color: var(--blue); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.muted { color: var(--text-3); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }
.field-block { display: flex; flex-direction: column; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 46px 24px;
  gap: 8px;
}
.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text-3);
  margin-bottom: 4px;
}
.empty-icon .icon { width: 24px; height: 24px; }
.empty strong { font-size: 13.5px; font-weight: 600; }
.empty p { max-width: 300px; color: var(--text-3); font-size: 12px; line-height: 1.65; }

/* Keyframes */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }
@keyframes shimmer { from { background-position: -300px 0; } to { background-position: 300px 0; } }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 0 rgba(15,174,147,.35); } 50% { box-shadow: 0 0 0 5px rgba(15,174,147,0); } }
@keyframes progress-slide { from { transform: translateX(-100%); } to { transform: translateX(350%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
