:root {
  --bg: #030914;
  --bg-soft: #07111f;
  --panel: #091729;
  --panel-2: #0b1b30;
  --line: #26384f;
  --line-soft: rgba(132, 155, 187, .16);
  --text: #f8f9fc;
  --muted: #8e9bb1;
  --gold: #f2ba45;
  --gold-2: #ffd570;
  --purple: #aa7bf8;
  --green: #4ed38a;
  --blue: #60a8ff;
  --red: #ff6f7f;
  --shadow: 0 18px 55px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { background: var(--bg); color-scheme: dark; }
body { margin: 0; background: radial-gradient(circle at 82% 5%, rgba(45, 79, 128, .12), transparent 30rem), var(--bg); color: var(--text); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; display: flex; width: 250px; flex-direction: column; border-right: 1px solid var(--line); background: rgba(3, 10, 21, .98); box-shadow: 14px 0 48px rgba(0, 0, 0, .16); }
.brand { display: flex; min-height: 100px; align-items: center; gap: 12px; padding: 0 25px; border-bottom: 1px solid var(--line-soft); }
.brand-mark, .auth-brand > span { display: grid; width: 43px; height: 43px; flex: 0 0 43px; place-items: center; border: 1px solid rgba(255, 213, 112, .75); border-radius: 13px; background: linear-gradient(145deg, #f7ca62, #bc7916); color: #181003; font-size: 22px; font-weight: 850; box-shadow: 0 8px 28px rgba(226, 157, 41, .2); }
.brand strong, .brand small, .auth-brand strong, .auth-brand small { display: block; }
.brand strong, .auth-brand strong { color: var(--gold-2); font-size: 19px; letter-spacing: -.03em; }
.brand small, .auth-brand small { margin-top: 1px; color: #748298; font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.sidebar nav { display: flex; flex: 1; flex-direction: column; gap: 5px; padding: 24px 12px; }
.sidebar nav a { position: relative; display: flex; align-items: center; gap: 16px; padding: 13px 16px; border: 1px solid transparent; border-radius: 11px; color: #aeb8c8; transition: .16s ease; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .035); color: #fff; }
.sidebar nav a.active { border-color: rgba(244, 189, 79, .1); background: linear-gradient(90deg, rgba(244, 189, 79, .17), rgba(244, 189, 79, .035)); color: var(--gold-2); }
.sidebar nav a.active::before { position: absolute; inset: 8px auto 8px -13px; width: 3px; border-radius: 0 3px 3px 0; background: var(--gold); content: ""; }
.nav-icon { display: grid; width: 21px; place-items: center; font-size: 22px; line-height: 1; }
.automation-status { display: flex; align-items: flex-start; gap: 10px; margin: 12px; padding: 14px; border: 1px solid rgba(78, 211, 138, .16); border-radius: 12px; background: rgba(78, 211, 138, .045); }
.automation-status i { width: 8px; height: 8px; flex: 0 0 8px; margin-top: 5px; border-radius: 999px; background: var(--green); box-shadow: 0 0 0 4px rgba(78, 211, 138, .1), 0 0 14px rgba(78, 211, 138, .5); }
.automation-status strong, .automation-status small { display: block; }
.automation-status strong { color: #cef5de; font-size: 11px; }
.automation-status small { margin-top: 3px; color: #718478; font-size: 9px; }

.main-area { min-height: 100vh; margin-left: 250px; }
.topbar { position: sticky; top: 0; z-index: 25; display: flex; height: 76px; align-items: center; gap: 16px; padding: 0 30px; border-bottom: 1px solid rgba(71, 90, 118, .28); background: rgba(4, 11, 22, .88); backdrop-filter: blur(18px); }
.global-search { display: flex; width: min(440px, 42vw); height: 43px; align-items: center; gap: 11px; padding: 0 15px; border: 1px solid #293b53; border-radius: 9px; background: rgba(8, 20, 36, .82); color: #75849b; }
.global-search:focus-within { border-color: rgba(244, 189, 79, .52); box-shadow: 0 0 0 3px rgba(244, 189, 79, .07); }
.global-search span { font-size: 25px; transform: rotate(-18deg); }
.global-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.avatar { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold-2); font-weight: 800; }
.user-menu strong, .user-menu small { display: block; }
.user-menu strong { font-size: 12px; }
.user-menu small { color: var(--muted); font-size: 10px; }
.user-menu > a { margin-left: 6px; color: var(--muted); font-size: 20px; }
.menu-toggle { display: none; }

.content { max-width: 1500px; margin: 0 auto; padding: 38px 34px 70px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 30px; }
.page-heading h1 { margin: 2px 0 0; font-size: clamp(32px, 4vw, 47px); line-height: 1.05; letter-spacing: -.045em; }
.eyebrow { margin: 0; color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }

.primary-button, .secondary-button { display: inline-flex; min-height: 42px; align-items: center; justify-content: center; gap: 8px; padding: 0 18px; border-radius: 9px; font-weight: 750; transition: .16s ease; }
.primary-button { border: 1px solid #ffd471; background: linear-gradient(145deg, #f7cb64, #d99a27); color: #160f04; box-shadow: 0 8px 26px rgba(226, 157, 41, .18); }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.05); }
.secondary-button { border: 1px solid #324864; background: #0c1c30; color: #d6deea; }
.secondary-button:hover { border-color: #567498; background: #10243d; }
.secondary-button.small { min-height: 32px; padding: 0 10px; font-size: 11px; }
.gold-link { border: 0; background: none; color: var(--gold-2); font-weight: 700; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); color: var(--text); }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 22px; }
.stats-grid.compact { grid-template-columns: repeat(2, minmax(0, 260px)); }
.stat-card, .panel { border: 1px solid var(--line); border-radius: 13px; background: linear-gradient(145deg, rgba(11, 27, 48, .96), rgba(7, 17, 31, .96)); box-shadow: 0 10px 35px rgba(0, 0, 0, .12); }
.stat-card { min-height: 166px; padding: 24px; }
.stat-card small, .stat-card strong { display: block; }
.stat-card small { margin-top: 15px; color: var(--muted); }
.stat-card strong { margin-top: 4px; font-size: 25px; letter-spacing: -.03em; }
.stat-icon { display: grid; width: 43px; height: 43px; place-items: center; border: 1px solid currentColor; border-radius: 12px; background: rgba(255, 255, 255, .025); font-size: 22px; }
.stat-icon.gold { color: var(--gold); }.stat-icon.purple { color: var(--purple); }.stat-icon.green { color: var(--green); }.stat-icon.blue { color: var(--blue); }

.dashboard-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 18px; }
.panel { min-width: 0; }
.panel-title { display: flex; min-height: 69px; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--line-soft); }
.panel-title h2, .panel-title p { margin: 0; }
.panel-title h2 { font-size: 17px; letter-spacing: -.02em; }
.panel-title p { margin-top: 3px; color: var(--muted); font-size: 10px; }
.panel-title > a { color: var(--gold); font-size: 11px; font-weight: 700; }
.action-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 18px; padding: 16px 22px; border-bottom: 1px solid rgba(134, 155, 185, .1); }
.action-row:last-child { border-bottom: 0; }
.action-row strong, td strong, td small { display: block; }
.action-row small, td small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.action-row > span { color: var(--muted); font-size: 12px; }
.badge { display: inline-flex; min-height: 28px; align-items: center; justify-content: center; padding: 0 10px; border: 1px solid currentColor; border-radius: 8px; background: rgba(255, 255, 255, .02); font-size: 10px; white-space: nowrap; }
.badge.success { color: var(--green); }.badge.warning { color: var(--gold); }.badge.purple { color: var(--purple); }.badge.info { color: var(--blue); }.badge.danger { color: var(--red); }
.cycle-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: center; gap: 10px; min-height: 230px; padding: 28px; text-align: center; }
.cycle-flow div { display: grid; justify-items: center; }
.cycle-flow div > span { display: grid; width: 64px; height: 64px; margin-bottom: 13px; place-items: center; border: 1px solid var(--gold); border-radius: 999px; color: var(--gold); font-size: 25px; }
.cycle-flow strong, .cycle-flow small { display: block; }
.cycle-flow strong { font-size: 12px; }.cycle-flow small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.cycle-flow i { color: var(--gold); font-size: 25px; font-style: normal; }
.mini-stats { display: flex; justify-content: center; gap: 28px; padding: 17px 20px; border-top: 1px solid var(--line-soft); color: var(--muted); font-size: 10px; }
.mini-stats b { color: var(--text); }

.table-panel { overflow: hidden; }
.table-search { width: min(260px, 35vw); height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: #071423; color: var(--text); }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 13px 18px; border-bottom: 1px solid var(--line); color: #74839a; font-size: 9px; letter-spacing: .08em; text-align: left; text-transform: uppercase; }
td { padding: 15px 18px; border-bottom: 1px solid rgba(134, 155, 185, .1); color: #cfd6e1; font-size: 12px; vertical-align: middle; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
.actions { display: flex; align-items: center; gap: 8px; }
.empty { padding: 34px !important; color: var(--muted); text-align: center; }

.templates-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.template-card { padding-bottom: 20px; }
.template-card > label, .template-card > .form-grid, .template-card > button { margin: 15px 20px 0; }
.split-layout { display: grid; grid-template-columns: minmax(280px, .38fr) minmax(0, 1fr); align-items: start; gap: 18px; }
.sticky-form { position: sticky; top: 98px; padding-bottom: 22px; }
.sticky-form > label, .sticky-form > .form-grid, .sticky-form > button { margin: 15px 20px 0; }
.settings-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-layout .panel { padding-bottom: 22px; }
.settings-layout .form-grid { padding: 20px; }
.button-row { padding: 0 20px; }
.api-test-form { margin-top: 14px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
label { display: block; color: #b6c0cf; font-size: 10px; font-weight: 700; letter-spacing: .02em; }
input, select, textarea { width: 100%; margin-top: 6px; border: 1px solid #2b3d55; border-radius: 8px; outline: none; background: #071524; color: var(--text); }
input, select { height: 42px; padding: 0 12px; }
textarea { min-height: 82px; padding: 11px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: rgba(244, 189, 79, .6); box-shadow: 0 0 0 3px rgba(244, 189, 79, .07); }
.full { grid-column: 1 / -1; }
.checkbox-field { display: flex; align-items: center; gap: 8px; padding-top: 20px; }
.checkbox-field input { width: 16px; height: 16px; margin: 0; accent-color: var(--gold); }
.section-label { margin-top: 6px; padding-top: 15px; border-top: 1px solid var(--line-soft); color: var(--gold); font-size: 11px; font-weight: 800; }
.inline-form { display: flex; align-items: center; gap: 6px; }
.inline-form select { width: 100px; height: 32px; margin: 0; font-size: 10px; }
.switch input { display: none; }
.switch span { position: relative; display: block; width: 38px; height: 22px; border: 1px solid #3a4b61; border-radius: 999px; background: #101d2d; }
.switch span::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 999px; background: #728096; content: ""; transition: .15s; }
.switch input:checked + span { border-color: rgba(78, 211, 138, .5); background: rgba(78, 211, 138, .15); }
.switch input:checked + span::after { left: 19px; background: var(--green); }

.alert { margin-bottom: 20px; padding: 13px 16px; border: 1px solid currentColor; border-radius: 9px; background: rgba(255, 255, 255, .03); }
.alert.success { color: var(--green); }.alert.warning { color: var(--gold); }.alert.danger { color: var(--red); }

.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.is-open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 4, 10, .78); backdrop-filter: blur(6px); }
.modal-card { position: relative; z-index: 1; width: min(780px, 100%); max-height: 92vh; overflow: auto; padding: 26px; border: 1px solid #3a4c64; border-radius: 16px; background: linear-gradient(145deg, #0c1b2e, #06101e); box-shadow: var(--shadow); }
.modal-card.narrow { width: min(520px, 100%); }
.modal-close { position: absolute; top: 16px; right: 16px; width: 35px; height: 35px; border: 1px solid var(--line); border-radius: 8px; background: #0a1828; color: #aeb8c6; font-size: 22px; }
.modal-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; padding-right: 40px; }
.modal-heading h2, .modal-heading p { margin: 0; }.modal-heading h2 { font-size: 23px; }.modal-heading p { margin-top: 3px; color: var(--muted); font-size: 11px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 5px; }

.auth-body { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 0, rgba(75, 103, 145, .17), transparent 30rem), var(--bg); }
.auth-card, .install-card { width: min(440px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(145deg, #0b1b2f, #06101e); box-shadow: var(--shadow); }
.install-card { width: min(760px, 100%); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.auth-card h1, .install-card h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.auth-card > p, .install-card > p { margin: 5px 0 22px; }
.auth-form { display: grid; gap: 15px; }
.install-form { margin-top: 24px; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .settings-layout { grid-template-columns: 1fr; }
  .cycle-flow { min-height: 200px; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-101%); transition: .2s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .menu-toggle { display: grid; flex: 0 0 40px; place-items: center; }
  .content { padding: 28px 18px 55px; }
  .topbar { padding: 0 16px; }
  .global-search { width: 100%; }
  .user-menu > div { display: none; }
  .templates-grid, .split-layout { grid-template-columns: 1fr; }
  .sticky-form { position: static; }
}

@media (max-width: 580px) {
  .stats-grid, .stats-grid.compact, .form-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 136px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .page-heading .primary-button { width: 100%; }
  .action-row { grid-template-columns: 1fr auto; }
  .action-row > span { display: none; }
  .cycle-flow { grid-template-columns: 1fr; }
  .cycle-flow i { transform: rotate(90deg); }
  .full { grid-column: auto; }
  .checkbox-field { padding-top: 0; }
  .modal-card { padding: 21px; }
  .user-menu > a { display: none; }
}

