/* Yyildiz Admin — Bytebook-inspired design system */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --yy-primary: #075daa;
  --yy-primary-dark: #064f91;
  --yy-primary-10: #075daa1f;
  --yy-primary-soft: #cddfee;
  --yy-page: #eaf0fe;
  --yy-surface: #ffffff;
  --yy-surface-alt: #f6f6f6;
  --yy-surface-muted: #f4f4f4;
  --yy-border: #e1e1e1;
  --yy-border-soft: #d3d8e5b9;
  --yy-text: #242424;
  --yy-text-strong: #1e1e1e;
  --yy-muted: #767676;
  --yy-muted-2: #8c8c8c;
  --yy-success: #24ba57;
  --yy-success-bg: #e9f8ee;
  --yy-warning: #b45309;
  --yy-warning-bg: #fff4e5;
  --yy-danger: #e24646;
  --yy-danger-bg: #fde8e8;
  --yy-info-bg: #e6f7ff;
  --yy-radius: 10px;
  --yy-radius-pill: 999px;
  --yy-sidebar-collapsed: 72px;
  --yy-sidebar-expanded: 220px;
  --yy-topbar: 72px;
  --yy-shadow: 0 1px 3px rgba(7, 93, 170, 0.08), 0 4px 12px rgba(30, 30, 30, 0.04);
  --yy-font: 'Inter', system-ui, sans-serif;
  --yy-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Legacy aliases used by page scripts */
  --bg: var(--yy-surface);
  --s1: var(--yy-surface-muted);
  --s2: #eef2f8;
  --border: var(--yy-border);
  --border2: #cfd6e4;
  --text: var(--yy-text);
  --muted: var(--yy-muted);
  --muted2: var(--yy-muted-2);
  --green: var(--yy-success);
  --green-bg: var(--yy-success-bg);
  --green-b: #b8e6c8;
  --amber: var(--yy-warning);
  --amber-bg: var(--yy-warning-bg);
  --amber-b: #f0d4a8;
  --red: var(--yy-danger);
  --red-bg: var(--yy-danger-bg);
  --red-b: #f5bcbc;
  --blue: var(--yy-primary);
  --blue-bg: var(--yy-info-bg);
  --blue-b: #b8d4f0;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--yy-font);
  font-size: 14px;
  color: var(--yy-text);
  background: var(--yy-page);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.yy-shell-ready { overflow-x: hidden; }

.mono, .DM-Mono { font-family: var(--yy-mono); }
.serif { font-family: var(--yy-font); font-weight: 700; }

/* ─── App shell ─── */
.yy-app {
  display: flex;
  min-height: 100vh;
}

.yy-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--yy-sidebar-expanded);
  background: var(--yy-surface);
  border-right: 1px solid var(--yy-border-soft);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
}

.yy-sidebar.collapsed { width: var(--yy-sidebar-collapsed); }

.yy-brand {
  height: var(--yy-topbar);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid var(--yy-border);
  flex-shrink: 0;
}

.yy-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--yy-primary), var(--yy-primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}

.yy-brand-text { min-width: 0; }
.yy-brand-name { font-size: 14px; font-weight: 700; color: var(--yy-text-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.yy-brand-sub { font-size: 10px; color: var(--yy-muted); letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.yy-sidebar.collapsed .yy-brand-text { display: none; }

.yy-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.yy-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 14px;
  margin-bottom: 4px;
  border-radius: var(--yy-radius-pill);
  text-decoration: none;
  color: var(--yy-text);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.yy-nav-item:hover { background: var(--yy-primary-soft); color: var(--yy-primary); }
.yy-nav-item.active { background: var(--yy-primary-soft); color: var(--yy-primary); font-weight: 600; }

.yy-nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.yy-sidebar.collapsed .yy-nav-label { display: none; }
.yy-sidebar.collapsed .yy-nav-item { justify-content: center; padding: 0; }

.yy-sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--yy-border);
}

.yy-sidebar-toggle {
  width: 100%;
  height: 40px;
  border: 1px solid var(--yy-border);
  background: var(--yy-surface-alt);
  border-radius: var(--yy-radius);
  cursor: pointer;
  color: var(--yy-muted);
  font-size: 18px;
}

.yy-body {
  flex: 1;
  margin-left: var(--yy-sidebar-expanded);
  min-width: 0;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

.yy-sidebar.collapsed ~ .yy-body,
body.yy-sidebar-collapsed .yy-body { margin-left: var(--yy-sidebar-collapsed); }

.yy-topbar {
  height: var(--yy-topbar);
  background: var(--yy-surface);
  border-bottom: 1px solid var(--yy-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 16px;
}

.yy-topbar-left { min-width: 0; }
.yy-page-title { font-size: 20px; font-weight: 700; color: var(--yy-text-strong); }
.yy-breadcrumbs { font-size: 12px; color: var(--yy-muted); margin-top: 2px; }

.yy-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.yy-sync-pill {
  font-family: var(--yy-mono);
  font-size: 11px;
  color: var(--yy-muted);
  padding: 6px 12px;
  background: var(--yy-surface-muted);
  border-radius: var(--yy-radius-pill);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.yy-content {
  flex: 1;
  padding: 24px 28px 40px;
  max-width: 1600px;
  width: 100%;
}

/* ─── Buttons ─── */
.btn, .hbtn, .gbtn {
  font-family: var(--yy-font);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--yy-radius-pill);
  border: 1px solid var(--yy-border);
  background: var(--yy-surface);
  color: var(--yy-text);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover, .hbtn:hover { border-color: var(--yy-primary); color: var(--yy-primary); }
.btn.pri, .hbtn.primary, .btn-primary {
  background: var(--yy-primary);
  border-color: var(--yy-primary);
  color: #fff;
  box-shadow: var(--yy-shadow);
}
.btn.pri:hover, .hbtn.primary:hover { background: var(--yy-primary-dark); border-color: var(--yy-primary-dark); color: #fff; opacity: 1; }
.btn.green { background: var(--yy-success); border-color: var(--yy-success); color: #fff; }
.btn.red, .gbtn.danger { background: var(--yy-danger-bg); border-color: #f5bcbc; color: var(--yy-danger); }
.btn.red:hover, .gbtn.danger:hover { background: var(--yy-danger); color: #fff; }
.btn.amber { background: var(--yy-warning); border-color: var(--yy-warning); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 11px; }
.btn.ghost { background: transparent; }

.yy-btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--yy-surface);
  box-shadow: var(--yy-shadow);
  border: 1px solid var(--yy-border);
}

/* ─── Cards & stats ─── */
.cards, .yy-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.card, .yy-stat-card {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: var(--yy-radius);
  padding: 16px 18px;
  box-shadow: var(--yy-shadow);
}

.card-label, .yy-stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--yy-muted);
  margin-bottom: 8px;
}

.card-val, .yy-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--yy-text-strong);
  line-height: 1.2;
}

.card-sub, .yy-stat-sub {
  font-size: 11px;
  color: var(--yy-muted);
  margin-top: 6px;
  font-family: var(--yy-mono);
}

/* ─── Panels ─── */
.yy-panel {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: var(--yy-radius);
  box-shadow: var(--yy-shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.yy-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--yy-surface-alt);
  border-bottom: 1px solid var(--yy-border);
}

.yy-panel-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--yy-muted);
}

.yy-panel-body { padding: 18px; }

/* ─── Tabs (in-page) ─── */
.tabs, .yy-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  padding: 4px;
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: var(--yy-radius-pill);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab, .yy-tab {
  font-size: 13px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--yy-radius-pill);
  cursor: pointer;
  color: var(--yy-muted);
  border: none;
  background: transparent;
  white-space: nowrap;
  margin: 0;
}

.tab.active, .yy-tab.active {
  background: var(--yy-primary);
  color: #fff;
}

/* ─── Filters ─── */
.filters, .yy-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: var(--yy-radius);
}

.filter-label { font-size: 12px; color: var(--yy-muted); font-weight: 500; }

.fpill, .yy-chip {
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--yy-radius-pill);
  border: 1px solid var(--yy-border);
  background: var(--yy-surface);
  color: var(--yy-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.fpill.active, .yy-chip.active {
  background: var(--yy-primary);
  border-color: var(--yy-primary);
  color: #fff;
}

.search-input, .yy-search {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border);
  border-radius: var(--yy-radius-pill);
  padding: 8px 16px;
  font-size: 13px;
  color: var(--yy-text);
  outline: none;
  min-width: 220px;
  font-family: var(--yy-font);
}

.search-input:focus, .yy-search:focus {
  border-color: var(--yy-primary);
  box-shadow: 0 0 0 3px var(--yy-primary-10);
}

/* ─── Tables ─── */
.table-wrap, .yy-table-wrap {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: var(--yy-radius);
  overflow: hidden;
  box-shadow: var(--yy-shadow);
}

.tbl, .pl-table, .orders-table, .yy-table {
  width: 100%;
  border-collapse: collapse;
}

.tbl th, .pl-table th, .orders-table th, .yy-table th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--yy-muted);
  padding: 12px 16px;
  background: var(--yy-surface-alt);
  border-bottom: 1px solid var(--yy-border);
  text-align: left;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

.tbl td, .pl-table td, .orders-table td, .yy-table td {
  font-size: 13px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--yy-border);
  vertical-align: middle;
}

.tbl tbody tr:nth-child(odd) td, .yy-table tbody tr:nth-child(odd) td { background: var(--yy-surface-muted); }
.tbl tbody tr:hover td, .yy-table tbody tr:hover td { background: var(--yy-primary-10); }
.tbl tr:last-child td, .yy-table tr:last-child td { border-bottom: none; }

.tbl tr.yy-row-clickable { cursor: pointer; }

.tbl input, .var-input, .ao-field input, .sf input {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border);
  border-radius: 6px;
  padding: 6px 10px;
  font-family: var(--yy-mono);
  font-size: 12px;
}

/* ─── Status pills ─── */
.pill, .st-pill, .urg, .stage, .stock-pill, .int-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--yy-radius-pill);
  white-space: nowrap;
}

.pill-pending, .st-wait, .urg-3 { background: var(--yy-warning-bg); color: var(--yy-warning); }
.pill-confirmed, .st-ok, .urg-ok { background: var(--yy-success-bg); color: var(--yy-success); }
.pill-refunded, .st-bad, .urg-7 { background: var(--yy-danger-bg); color: var(--yy-danger); }
.pill-est, .stage-auto { background: var(--yy-info-bg); color: var(--yy-primary); }

.int-pill { border: 1px solid var(--yy-border); background: var(--yy-surface-muted); color: var(--yy-muted); }
.int-pill.ok { background: var(--yy-success-bg); color: var(--yy-success); border-color: #b8e6c8; }
.int-pill.warn { background: var(--yy-warning-bg); color: var(--yy-warning); }
.int-pill.err { background: var(--yy-danger-bg); color: var(--yy-danger); }

.profit-pos { color: var(--yy-success); font-weight: 600; }
.profit-neg { color: var(--yy-danger); font-weight: 600; }

/* ─── Integration / banners ─── */
.int-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.bd-blocked-banner, .connect-banner, .alert-banner {
  border-radius: var(--yy-radius);
  padding: 14px 18px;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
}

.connect-banner { background: var(--yy-warning-bg); border: 1px solid #f0d4a8; }
.bd-blocked-banner { background: var(--yy-warning-bg); border: 1px solid #f0d4a8; }

/* ─── Forms ─── */
.ao-field label, .sf label, .add-field label, .email-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--yy-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ao-field input, .sf input, .sf textarea, .add-field input, .email-field input, .email-field textarea {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border);
  border-radius: var(--yy-radius);
  padding: 10px 12px;
  font-size: 13px;
  width: 100%;
}

.ao-field input:focus, .sf input:focus { border-color: var(--yy-primary); outline: none; box-shadow: 0 0 0 3px var(--yy-primary-10); }

.add-order-panel, .add-panel, .setup-card {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: var(--yy-radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--yy-shadow);
}

/* ─── Order cards (mobile) ─── */
.order-cards { display: none; flex-direction: column; gap: 12px; }
.order-card {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: var(--yy-radius);
  padding: 16px;
  box-shadow: var(--yy-shadow);
  cursor: pointer;
}
.order-card:active { background: var(--yy-primary-10); }

/* ─── Drawer (order detail) ─── */
.yy-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 30, 30, 0.45);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.yy-drawer-overlay.open { opacity: 1; pointer-events: auto; }

.yy-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(480px, 100vw);
  background: var(--yy-surface);
  z-index: 501;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
}

.yy-drawer-overlay.open .yy-drawer { transform: translateX(0); }

.yy-drawer-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--yy-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.yy-drawer-title { font-size: 18px; font-weight: 700; }
.yy-drawer-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--yy-surface-muted);
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  color: var(--yy-muted);
}

.yy-drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px; }

.yy-detail-section { margin-bottom: 24px; }
.yy-detail-section h4 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--yy-muted);
  margin-bottom: 12px;
}

.yy-kv-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.yy-kv {
  background: var(--yy-surface-muted);
  border-radius: 8px;
  padding: 12px 14px;
}

.yy-kv.full { grid-column: 1 / -1; }

.yy-kv-label { font-size: 10px; color: var(--yy-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.yy-kv-val { font-size: 14px; font-weight: 600; font-family: var(--yy-mono); }

.yy-link-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

.yy-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--yy-radius-pill);
  background: var(--yy-primary-10);
  color: var(--yy-primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
}

.yy-link-btn:hover { border-color: var(--yy-primary); }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--yy-text-strong);
  color: #fff;
  border-radius: var(--yy-radius);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s;
  pointer-events: none;
  z-index: 9999;
  box-shadow: var(--yy-shadow);
}

.toast.show { opacity: 1; transform: translateY(0); }

.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--yy-muted);
  font-size: 14px;
}

/* ─── Login page ─── */
.yy-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--yy-page) 0%, #dce8fc 100%);
}

.yy-login-card {
  width: 100%;
  max-width: 420px;
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: 16px;
  padding: 36px 32px;
  box-shadow: 0 12px 40px rgba(7, 93, 170, 0.12);
}

.yy-login-logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--yy-primary), var(--yy-primary-dark));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  margin: 0 auto 16px;
}

/* ─── Hide legacy chrome when shell active ─── */
body.yy-shell-ready .hdr,
body.yy-shell-ready .header,
body.yy-shell-ready > .tabs:first-of-type,
body.yy-shell-ready .yy-bottom-nav { display: none !important; }

body.yy-shell-ready .main { max-width: none; padding: 0; }

.page { display: none; }
.page.active { display: block; }

.ao-preview{background:var(--yy-success-bg);border:1px solid #b8e6c8;border-radius:var(--yy-radius);padding:12px 16px;display:flex;gap:1.5rem;align-items:center;flex-wrap:wrap;margin-top:8px}
.pl-section{margin-bottom:24px}
.pl-title{font-size:12px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--yy-muted);margin-bottom:12px}
.connect-form{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.connect-form input{min-width:200px}

.dept, .goal-banner, .overview .ov-cell {
  background: var(--yy-surface);
  border: 1px solid var(--yy-border-soft);
  border-radius: var(--yy-radius);
  box-shadow: var(--yy-shadow);
}

/* ─── Responsive ─── */
@media (max-width: 900px) {
  .yy-sidebar { transform: translateX(-100%); width: var(--yy-sidebar-expanded); }
  .yy-sidebar.mobile-open { transform: translateX(0); }
  .yy-body { margin-left: 0 !important; }
  .yy-content { padding: 16px; }
  .yy-topbar { padding: 0 16px; }
  .yy-mobile-menu { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .cards { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 901px) {
  .yy-mobile-menu { display: none !important; }
  .desktop-only { display: block; }
  .mobile-only { display: none !important; }
}

@media print {
  .yy-sidebar, .yy-topbar, .yy-drawer-overlay, .filters, .tabs, .yy-toolbar { display: none !important; }
  .yy-body { margin-left: 0 !important; }
}
