/* Page layout v10: top bar with page tabs and actions, Files / Load / Sheets / Recipes / Admin pages,
   ribbon toolbar, sheet tabs, info icons and tooltips, login. Loaded after styles.css. */

:root { --ribbon: #fbfcfe; --tab-bg: #e9edf3; --ok: #2f9e5b; --warn: #b7791f; }
@media (prefers-color-scheme: dark) {
  :root { --ribbon: #181c22; --tab-bg: #232933; --ok: #4cc27a; --warn: #e0a84a; }
}

/* ---------- top bar */
.topbar { gap: 14px; padding: 8px 16px; position: relative; z-index: 30; }
.topbar .brand { white-space: nowrap; }
.nav { display: flex; gap: 2px; margin-left: 18px; }
.nav-tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border: none; background: none;
  border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 600;
}
.nav-tab:hover { background: var(--skipped); color: var(--text); }
.nav-tab.active { background: var(--accent-soft); color: var(--accent); }
.nav-num {
  width: 20px; height: 20px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; background: var(--border); color: var(--text);
}
.nav-tab.active .nav-num { background: var(--accent); color: #fff; }
.nav-count { font-size: 11px; padding: 0 7px; border-radius: 999px; background: var(--skipped); color: var(--muted); font-weight: 600; }
.actions { display: flex; align-items: center; gap: 12px; }
.action { display: inline-flex; align-items: center; gap: 3px; }
.user-btn { color: var(--muted); }
.retention {
  padding: 6px 16px; font-size: 12.5px; background: color-mix(in srgb, var(--accent-soft) 70%, var(--panel));
  border-bottom: 1px solid var(--border); color: var(--text);
}

/* ---------- info icon + tooltip */
.info {
  display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; margin-left: 4px;
  border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); font: italic 700 10px/1 Georgia, serif;
  cursor: help; vertical-align: middle; flex-shrink: 0; user-select: none;
}
.info:hover, .info:focus { border-color: var(--accent); color: #fff; background: var(--accent); outline: none; }
.tip {
  position: fixed; z-index: 200; max-width: 340px; padding: 10px 12px; border-radius: 8px;
  background: #1d2430; color: #f2f5f9; box-shadow: var(--shadow); font-size: 12.5px; line-height: 1.45; pointer-events: none;
}
.tip b { display: block; margin-bottom: 3px; font-size: 13px; }

/* ---------- pages */
main { padding: 16px 22px 10px; gap: 12px; }
.page-head { display: flex; align-items: center; gap: 12px; }
.page-head h1 { margin: 0; font-size: 21px; display: inline-flex; align-items: center; gap: 4px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: auto; }
.empty-state {
  margin: 30px auto; max-width: 560px; text-align: center; color: var(--muted); line-height: 1.6;
  padding: 26px; border: 1px dashed var(--border); border-radius: 12px; background: var(--panel);
}
.hint.small { font-size: 11.5px; }
.pad { padding: 10px 14px; margin: 0; }
.list-head { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); }

/* files page */
.drop-target {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; cursor: pointer;
  border: 2px dashed var(--border); border-radius: 12px; background: var(--panel); color: var(--muted); text-align: center;
}
.drop-target:hover { border-color: var(--accent); color: var(--accent); }
.drop-icon { font-size: 26px; }
.list-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.list-table th { text-align: left; padding: 9px 12px; background: var(--grid-head); font-weight: 600; font-size: 12.5px; color: var(--muted); }
.list-table td { padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.list-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.list-table tr.disabled td { opacity: .55; }
.file-icon { margin-right: 6px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: 6px; }
.chip-link {
  display: inline-block; margin: 2px 6px 2px 0; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft);
  color: var(--accent); text-decoration: none; font-size: 12.5px;
}
.icon-btn.danger:hover { color: var(--danger); }

/* load page */
.toolbar.picker { margin-bottom: 0; }
.toolbar .ctl { display: inline-flex; align-items: center; gap: 6px; }
.toolbar label { display: inline-flex; align-items: center; gap: 6px; }
.page-load .grid-wrap { flex: 1; min-height: 260px; }

/* ---------- sheets page: ribbon */
.page-sheets { padding-top: 10px; padding-bottom: 0; gap: 8px; }
.ribbon {
  display: flex; flex-wrap: wrap; gap: 0; background: var(--ribbon); border: 1px solid var(--border); border-radius: 10px;
  padding: 4px 4px 0;
}
.rgroup { display: flex; flex-direction: column; padding: 2px 8px 0; border-right: 1px solid var(--border); }
.rgroup:last-child { border-right: none; }
.rbtns { display: flex; flex-wrap: wrap; gap: 2px; align-items: center; max-width: 520px; }
.ritem { display: inline-flex; align-items: center; margin-right: 4px; }
.rbtn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border: 1px solid transparent; border-radius: 6px;
  background: none; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.rbtn:hover { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent); }
.rbtn.on { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); font-weight: 600; }
.ricon { width: 18px; text-align: center; color: var(--accent); font-weight: 700; }
.ritem .info { margin-left: 0; width: 13px; height: 13px; font-size: 9px; opacity: .55; }
.ritem:hover .info, .ritem .info:focus { opacity: 1; }
.rlabel {
  text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0 4px; letter-spacing: .02em;
  display: flex; justify-content: center; align-items: center; gap: 2px;
}

/* sheet header line */
.sheet-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sheet-title { margin: 0; font-size: 19px; cursor: pointer; }
.sheet-title .edit-hint { color: var(--muted); font-size: 14px; visibility: hidden; }
.sheet-title:hover .edit-hint { visibility: visible; }
.sheet-head .meta { margin: 0; }
.badge.final { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.viewing.danger { color: var(--danger); }
.page-sheets .table-area { min-height: 260px; }

/* sheet tabs (bottom, like Excel) */
.sheet-tabs {
  display: flex; align-items: flex-end; gap: 2px; padding: 6px 4px 0; overflow-x: auto; flex-shrink: 0;
  border-top: 1px solid var(--border); margin: 0 -22px; padding-left: 18px;
}
.sheet-tabs > .info { align-self: center; margin-right: 6px; }
.sheet-tab {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border: 1px solid var(--border); border-bottom: none;
  border-radius: 8px 8px 0 0; background: var(--tab-bg); cursor: pointer; white-space: nowrap; font-size: 13px; color: var(--muted);
}
.sheet-tab:hover { color: var(--text); }
.sheet-tab.active { background: var(--panel); color: var(--accent); font-weight: 600; box-shadow: 0 -2px 0 var(--accent) inset; }
.sheet-tab.error { color: var(--danger); }
.sheet-tab.add { font-weight: 700; padding: 6px 12px; }
.tab-final { color: var(--ok); font-weight: 700; }
.tab-name { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.tab-menu { border: none; background: none; cursor: pointer; color: inherit; padding: 0 2px; }

/* ---------- recipes page */
.recipes-page { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; min-height: 0; }
.recipe-list { display: flex; flex-direction: column; }
.recipe-item {
  text-align: left; padding: 10px 14px; border: none; border-top: 1px solid var(--border); background: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.recipe-item:hover { background: var(--skipped); }
.recipe-item.active { background: var(--accent-soft); box-shadow: 3px 0 0 var(--accent) inset; }
.recipe-item-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.recipe-detail { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.recipe-title { margin: 0; font-size: 18px; }
.recipe-layout { grid-template-columns: minmax(380px, 1.2fr) 1fr; }
.btn.on { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); border-color: var(--ok); }

/* ---------- admin page */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.stat-value { font-size: 16px; font-weight: 600; margin-top: 4px; }
.add-user { display: flex; gap: 8px; padding: 12px 14px; flex-wrap: wrap; }
.add-user .input { min-width: 200px; }
.danger-btn:hover { border-color: var(--danger); color: var(--danger); }

/* ---------- dialogs & misc */
.dialog.narrow { width: min(420px, 100%); }
.drawer-head h2 { display: inline-flex; align-items: center; gap: 4px; }
.form-label { display: flex; align-items: center; gap: 4px; }

/* ---------- login */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); z-index: 90; }
.login-card {
  width: min(400px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 28px; display: flex; flex-direction: column; gap: 12px;
}
.brand.big { font-size: 22px; }
.login-card .input { padding: 9px 12px; font-size: 15px; }
.login-card .btn.primary { justify-content: center; padding: 9px; font-size: 15px; }
.login-error { color: var(--danger); min-height: 18px; font-size: 13px; }

/* ---------- v11: two-row toolbar, separate Recipes tab */
.ribbon { flex-direction: column; gap: 2px; padding: 4px 6px; }
.rrow { display: flex; flex-wrap: wrap; gap: 2px; }
.nav-tab.separate { margin-left: 14px; position: relative; }
.nav-tab.separate::before { content: ""; position: absolute; left: -8px; top: 20%; height: 60%; border-left: 1px solid var(--border); }

/* ---------- dashboard editor & dialogs */
.dialog.wide { width: min(940px, 100%); max-height: 90vh; display: flex; flex-direction: column; }
.dialog.wide .editor-body { overflow: auto; flex: 1; }
.editor-h { margin: 8px 0 0; font-size: 15px; }
.cat-block { border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.cat-name { font-weight: 600; }
.folder-row { padding-left: 22px; }
.tool-edit { border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.status-select { flex: 0 0 150px !important; }
.places summary { cursor: pointer; font-size: 13px; padding: 2px 0; }
.places-list { display: flex; flex-direction: column; gap: 3px; padding: 6px 4px 2px; max-height: 260px; overflow: auto; }
.places-list label { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.places-list label.sub { padding-left: 24px; }
.cat-edit-list { display: flex; flex-direction: column; gap: 6px; }
.cat-edit-row { display: flex; align-items: center; gap: 6px; }
.cat-edit-row .input { flex: 1; }
.cat-tool-name { flex: 1; font-weight: 600; }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-body textarea.input { resize: vertical; font: inherit; }


/* ---------- ribbon: "+ Add column" stands out */
.rbtn.primary-action { background: var(--accent); color: #fff; font-weight: 600; }
.rbtn.primary-action .ricon { color: #fff; }
.rbtn.primary-action:hover { background: var(--accent); filter: brightness(1.08); color: #fff; }

/* ---------- admin tabs */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.admin-tab { padding: 8px 14px; border: none; background: none; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.admin-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tool-checks { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; }
.tool-checks label, .check-line { display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pill { display: inline-block; white-space: nowrap; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; background: var(--skipped); color: var(--muted); margin: 1px 3px 1px 0; }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.fb-msg { white-space: pre-wrap; max-width: 520px; }

/* ---------- narrower screens (the 1·2·3 step numbers stay visible on iPads) */
.topbar .btn { white-space: nowrap; }
@media (max-width: 1100px) { .btn-label { display: none; } .actions .info { display: none; } }
@media (max-width: 1250px) {
  .nav-tab { padding: 7px 10px; }
  .brand-sub { display: none; }
  .nav { margin-left: 6px; }
  .actions { gap: 6px; }
  .recipes-page { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .ap-panel { display: none; }
}
