/* Admin: calm, spacious, system-like. Warm neutral canvas, white surfaces, one accent (IPH burgundy). */
:root {
  --canvas: #F6F2EC;
  --surface: #FFFFFF;
  --text: #261219;
  --text-2: #75656B;
  --text-3: #A69AA0;
  --accent: #561B2F;
  --accent-soft: rgba(86, 27, 47, .08);
  --hair: rgba(38, 18, 25, .08);
  --hair-2: rgba(38, 18, 25, .14);
  --fill: rgba(38, 18, 25, .055);
  --track: #E9E3DA;
  --ok: #2B6B3C; --ok-soft: rgba(43, 107, 60, .11);
  --bad: #B3261E; --bad-soft: rgba(179, 38, 30, .09);
  --shadow-1: 0 1px 2px rgba(38, 18, 25, .04), 0 10px 28px -14px rgba(38, 18, 25, .14);
  --shadow-pop: 0 2px 6px rgba(38, 18, 25, .08), 0 24px 48px -16px rgba(38, 18, 25, .32);
  --r-card: 20px; --r-ctl: 12px; --nav: 56px;
}
body { background: var(--canvas); color: var(--text); line-height: 1.5; letter-spacing: -.005em; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* ---------- buttons ---------- */
.b { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 36px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--fill); color: var(--text); font-size: .8125rem; font-weight: 600; letter-spacing: 0; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .18s, transform .18s, box-shadow .18s, opacity .18s; -webkit-tap-highlight-color: transparent; }
.b:hover { background: rgba(38, 18, 25, .09); }
.b:active { transform: scale(.975); }
.b:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.b svg { flex: none; }
.b--primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(38, 18, 25, .2), 0 6px 14px -8px rgba(86, 27, 47, .7); }
.b--primary:hover { background: #6a2339; }
.b--soft { background: var(--accent-soft); color: var(--accent); }
.b--soft:hover { background: rgba(86, 27, 47, .14); }
.b--text { min-height: 32px; padding: 0 10px; background: transparent; color: var(--accent); }
.b--text:hover { background: var(--accent-soft); }
.b--danger { background: var(--bad-soft); color: var(--bad); }
.b--danger:hover { background: rgba(179, 38, 30, .16); }
.b--lg { min-height: 46px; padding: 0 22px; border-radius: 14px; font-size: .95rem; }
.b--block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--fill); color: var(--text-2); cursor: pointer; transition: background-color .18s, color .18s; }
.icon-btn:hover { background: rgba(38, 18, 25, .09); color: var(--text); }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: radial-gradient(90% 70% at 85% 0%, #7a2a49 0%, transparent 60%), linear-gradient(170deg, #561B2F 0%, #36111F 100%); position: relative; isolation: isolate; overflow: hidden; }
.login::before { content: ""; position: absolute; inset: 0; z-index: -1; background: url("assets/pattern.svg") 0 0 / 200px 200px; opacity: .12; }
.login__card { width: min(400px, 100%); padding: 40px 32px 32px; border-radius: 28px; background: var(--surface); box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .65); animation: rise .7s var(--ease-out) both; }
.login__logo { display: flex; justify-content: center; margin: -88px 0 22px; }
.login__logo .lockup { --M: 62px; color: var(--ivory); background: var(--accent); padding: 14px 24px; border-radius: 20px; box-shadow: 0 18px 36px -16px rgba(0, 0, 0, .65); }
.login h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; text-align: center; }
.login p { margin: 6px 0 24px; text-align: center; color: var(--text-2); font-size: .92rem; }
.err { margin: 0 0 14px; padding: 10px 14px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-size: .88rem; }
.label { display: block; margin: 0 0 7px 2px; font-size: .75rem; font-weight: 600; color: var(--text-2); letter-spacing: .02em; }
.input { display: block; width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid transparent; border-radius: var(--r-ctl); background: var(--fill); color: var(--text); font-size: .95rem; outline: none; transition: background-color .18s, border-color .18s, box-shadow .18s; }
.input::placeholder { color: var(--text-3); }
.input:focus { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(86, 27, 47, .12); }
textarea.input { min-height: 110px; resize: vertical; line-height: 1.55; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2375656B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-inline-end: 38px; }
html[dir="rtl"] select.input { background-position: left 14px center; }
.login .b { margin-top: 18px; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--nav); background: rgba(54, 17, 31, .86); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); box-shadow: 0 1px 0 rgba(255, 242, 222, .08); }
.topbar__in { display: flex; align-items: center; gap: 14px; max-width: 1120px; height: 100%; margin: 0 auto; padding: 0 clamp(16px, 3vw, 28px); }
.topbar .lockup { --M: 34px; }
.topbar__title { font-size: .92rem; font-weight: 600; letter-spacing: .01em; color: var(--ivory); padding-inline-start: 14px; border-inline-start: 1px solid rgba(255, 242, 222, .22); white-space: nowrap; }
.topbar__spacer { flex: 1; }
.topbar .b { min-height: 34px; background: rgba(255, 242, 222, .12); color: var(--ivory); box-shadow: none; }
.topbar .b:hover { background: rgba(255, 242, 222, .2); }
.topbar .b--gold { background: var(--gold-grad); color: var(--burgundy); }
.topbar .b--gold:hover { filter: brightness(1.06); }
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel { position: absolute; z-index: 40; inset-inline-end: 0; top: calc(100% + 8px); min-width: 250px; padding: 6px; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); border: 1px solid var(--hair); animation: pop .18s var(--ease-out) both; }
.menu__panel a { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 10px; font-size: .88rem; font-weight: 500; text-decoration: none; }
.menu__panel a:hover { background: var(--fill); }
.menu__panel a svg { color: var(--text-3); flex: none; }
.menu__panel hr { margin: 6px 8px; border: 0; border-top: 1px solid var(--hair); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- page ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 36px clamp(16px, 3vw, 28px) 96px; }
.hero h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); font-weight: 700; letter-spacing: -.035em; line-height: 1.1; }
.hero p { margin-top: 8px; max-width: 60ch; color: var(--text-2); font-size: 1rem; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 28px 0 8px; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-card); box-shadow: var(--shadow-1); }
.stat { padding: 18px 22px; border-inline-start: 1px solid var(--hair); }
.stat:first-child { border-inline-start: 0; }
.stat b { display: block; font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 2px; font-size: .78rem; color: var(--text-2); }

/* ---------- sticky controls ---------- */
.controls { position: sticky; top: var(--nav); z-index: 20; margin: 0 calc(-1 * clamp(16px, 3vw, 28px)); padding: 14px clamp(16px, 3vw, 28px) 12px; background: rgba(246, 242, 236, .82); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); }
.controls::after { content: ""; position: absolute; inset-inline: 0; bottom: 0; height: 1px; background: var(--hair); }
.controls__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.controls__row + .controls__row { margin-top: 12px; }

/* segmented control */
.segmented { display: inline-flex; gap: 2px; padding: 3px; border-radius: 12px; background: var(--track); }
.segmented button { display: inline-flex; align-items: center; gap: 8px; min-height: 34px; padding: 0 16px; border: 0; border-radius: 9px; background: transparent; color: var(--text-2); font-size: .85rem; font-weight: 600; letter-spacing: 0; cursor: pointer; white-space: nowrap; transition: background-color .2s, color .2s, box-shadow .2s; }
.segmented button:hover { color: var(--text); }
.segmented button[aria-selected="true"], .segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(38, 18, 25, .12), 0 3px 8px -2px rgba(38, 18, 25, .12); }
.segmented small { font-size: .72rem; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.segmented button[aria-selected="true"] small { color: var(--accent); }
.segmented--lg button { min-height: 40px; padding: 0 20px; font-size: .9rem; }
.segmented--sm button { min-height: 30px; padding: 0 12px; font-size: .78rem; }

.search { position: relative; flex: 1 1 260px; max-width: 460px; }
.search svg { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { min-height: 40px; padding-inline-start: 38px; }
.field-inline { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: .78rem; font-weight: 600; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 94%, transparent); mask-image: linear-gradient(90deg, #000 94%, transparent); }
.chips::-webkit-scrollbar { display: none; }
.chip-f { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 13px; border: 1px solid var(--hair-2); border-radius: 999px; background: transparent; color: var(--text); font-size: .78rem; font-weight: 600; cursor: pointer; transition: background-color .18s, color .18s, border-color .18s; }
.chip-f:hover { background: var(--fill); }
.chip-f small { font-size: .7rem; color: var(--text-3); font-weight: 600; }
.chip-f[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-f[aria-pressed="true"] small { color: rgba(255, 255, 255, .7); }

/* ---------- sections + lists ---------- */
.view { animation: fade .35s both; }
.section { margin-top: 32px; }
.section__head { display: flex; align-items: center; gap: 10px; margin: 0 4px 10px; }
.section__head h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.015em; }
.section__head .n { color: var(--text-3); font-size: .85rem; font-weight: 600; }
.section__head .spacer { flex: 1; }
.section__note { margin: -4px 4px 12px; color: var(--text-2); font-size: .88rem; max-width: 72ch; }
.list { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-card); box-shadow: var(--shadow-1); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 14px 18px; border-top: 1px solid var(--hair); transition: background-color .15s; }
.row:first-child { border-top: 0; border-radius: var(--r-card) var(--r-card) 0 0; }
.row:last-child { border-radius: 0 0 var(--r-card) var(--r-card); }
.row:only-child { border-radius: var(--r-card); }
.row:hover { background: rgba(38, 18, 25, .018); }
.row__title { font-size: .95rem; font-weight: 600; letter-spacing: -.01em; line-height: 1.35; overflow-wrap: anywhere; }
.row__sub { margin-top: 1px; color: var(--text-2); font-size: .8rem; overflow-wrap: anywhere; }
.row__meta { display: flex; align-items: center; gap: 7px; margin-top: 6px; color: var(--text-2); font-size: .78rem; min-width: 0; }
.row__meta span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); opacity: .55; }
.dot--on { background: #2F9E52; opacity: 1; box-shadow: 0 0 0 3px rgba(47, 158, 82, .18); }
.row__actions { display: flex; align-items: center; gap: 6px; }
.badge-n { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700; }
.badge-n--zero { background: rgba(38, 18, 25, .1); color: var(--text-2); }
.more { position: relative; }
.more > summary { list-style: none; cursor: pointer; }
.more > summary::-webkit-details-marker { display: none; }
.more__panel { position: absolute; z-index: 15; inset-inline-end: 0; top: calc(100% + 6px); min-width: 230px; padding: 6px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-pop); border: 1px solid var(--hair); animation: pop .16s var(--ease-out) both; }
.more__panel a { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 38px; padding: 0 12px; border-radius: 10px; font-size: .85rem; font-weight: 500; text-decoration: none; color: var(--text); }
.more__panel a:hover { background: var(--fill); }
.more__panel a svg { color: var(--text-3); flex: none; }
.empty { padding: 72px 20px; text-align: center; color: var(--text-2); }
.empty b { display: block; margin-bottom: 4px; color: var(--text); font-size: 1.05rem; }

/* ---------- drawer (sheet) ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: rgba(38, 18, 25, .38); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: fade .25s both; }
.drawer { position: fixed; z-index: 51; top: 10px; bottom: 10px; inset-inline-end: 10px; width: min(480px, calc(100% - 20px)); display: flex; flex-direction: column; border-radius: 26px; background: var(--canvas); box-shadow: var(--shadow-pop); overflow: hidden; animation: sheetIn .5s var(--ease-out) both; }
@keyframes sheetIn { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }
html[dir="rtl"] .drawer { animation-name: sheetInR; }
@keyframes sheetInR { from { transform: translateX(-32px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer__head { position: relative; padding: 24px 26px 18px; background: var(--surface); border-bottom: 1px solid var(--hair); }
.eyebrow-s { display: block; margin-bottom: 4px; color: var(--accent); font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.drawer__head h2 { margin-inline-end: 44px; font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
.drawer__head p { margin-top: 3px; color: var(--text-2); font-size: .88rem; }
.drawer__close { position: absolute; top: 18px; inset-inline-end: 18px; }
.drawer__body { flex: 1; overflow: auto; padding: 22px 26px 34px; }
.drawer h3 { display: flex; align-items: baseline; gap: 8px; margin: 28px 2px 10px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.drawer h3:first-child { margin-top: 0; }
.drawer h3 .n { font-weight: 600; color: var(--text-3); letter-spacing: 0; text-transform: none; }
.linkbox { display: flex; gap: 8px; }
.linkbox .input { min-width: 0; min-height: 40px; font-size: .8rem; direction: ltr; }
.linkbox .b { min-height: 40px; }
.qlinks { margin-top: 12px; }
.qlinks .row { grid-template-columns: 1fr; padding: 0; }
.qlinks .row a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 0 16px; text-decoration: none; font-size: .88rem; font-weight: 500; }
.qlinks .row a svg { color: var(--text-3); }
.qlinks .row:hover { background: var(--fill); }
.pos { display: grid; gap: 10px; padding: 14px 16px; margin-bottom: 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--hair); box-shadow: var(--shadow-1); }
.pos__top { display: flex; align-items: center; gap: 10px; }
.pos__title { flex: 1; min-width: 0; font-weight: 600; font-size: .92rem; overflow-wrap: anywhere; }
.status { padding: 2px 10px; border-radius: 99px; font-size: .68rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.status--Open { background: var(--ok-soft); color: var(--ok); }
.status--Closed { background: var(--bad-soft); color: var(--bad); }
.status--Draft { background: var(--fill); color: var(--text-2); }
.pos__meta { font-size: .8rem; color: var(--text-2); }
.pos__actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pos__actions .b { min-height: 32px; padding: 0 12px; }
.pos__edit { display: grid; gap: 8px; }
.add { margin-top: 14px; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px dashed var(--hair-2); display: grid; gap: 12px; }
.add__row { display: flex; gap: 8px; }
.add__row .input { flex: 1; min-width: 0; }
.add__row .b { min-height: 44px; }
.linklike { justify-self: start; border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; font-size: .82rem; cursor: pointer; }
.linklike:hover { text-decoration: underline; text-underline-offset: 3px; }
.hint { color: var(--text-2); font-size: .85rem; margin: 0 2px 10px; }

.toast { position: fixed; z-index: 80; bottom: 28px; inset-inline-start: 50%; transform: translateX(-50%); padding: 11px 20px; border-radius: 999px; background: rgba(38, 18, 25, .92); color: #fff; font-size: .85rem; font-weight: 500; box-shadow: var(--shadow-pop); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: rise .3s var(--ease-out) both; }
html[dir="rtl"] .toast { transform: translateX(50%); }
.toast--bad { background: var(--bad); }

/* ---------- responsive ---------- */
@media (max-width: 820px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-inline-start: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--hair); }
}
@media (max-width: 720px) {
  .topbar__title { display: none; }
  .topbar .lockup__word { display: none !important; }
  .page { padding-top: 24px; }
  .segmented--lg { display: flex; width: 100%; }
  .segmented--lg button { flex: 1; justify-content: center; padding: 0 8px; font-size: .8rem; }
  .segmented--lg small { display: none; }
  .row { grid-template-columns: 1fr; gap: 12px; }
  .row__actions { width: 100%; }
  .row__actions .b--primary { flex: 1; }
  .more__panel { inset-inline-end: 0; }
  .drawer { inset: 0; width: 100%; border-radius: 0; }
  .field-inline > span:first-child { display: none; }
  .controls { position: static; background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; padding-top: 18px; }
  .controls__row:first-child { justify-content: space-between; }
  .search { max-width: none; flex-basis: 100%; }
}

/* ---- new form dialog */
.dlg { position: fixed; z-index: 61; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow: auto; padding: 26px; border-radius: 26px; background: var(--canvas); box-shadow: var(--shadow-pop); }
.dlg[hidden], #nfScrim[hidden] { display: none; }
#nfScrim { z-index: 60; }
.dlg h2 { margin: 0 0 6px; font-size: 1.25rem; }
.dlg__note { margin: 0 0 18px; color: var(--text-2); font-size: .86rem; line-height: 1.5; }
.dlg__free { margin: 14px 2px 0; color: var(--text-2); font-size: .78rem; font-weight: 600; }
.dlg__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.dlg__ok { margin: 6px 0 14px; font-weight: 600; }
.dlg .opt { color: var(--text-2); font-weight: 500; }

/* ---- accounts, activity, restore */
.me { display: inline-flex; align-items: center; padding: 0 10px; font-size: .78rem; font-weight: 600; color: var(--gold-soft, #f0d9bd); white-space: nowrap; }
.boot { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--canvas, #fff6ea); }
.boot[hidden] { display: none; }
.boot span { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(86, 27, 47, .18); border-top-color: #561b2f; animation: bootspin .8s linear infinite; }
@keyframes bootspin { to { transform: rotate(360deg); } }
.acc-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-top: 6px; }
.acc-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
#tabAcc[hidden], #tabLog[hidden] { display: none; }

/* ---- user menu in the top bar, no horizontal page scroll */
.menu__panel button { display: flex; align-items: center; width: 100%; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; font-size: .88rem; font-weight: 500; text-align: start; cursor: pointer; }
.menu__panel button:hover { background: var(--fill); }
.menu__panel button[hidden] { display: none; }
#meChip { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html, body { overflow-x: clip; }
.segmented--lg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented--lg::-webkit-scrollbar { display: none; }
.segmented--sm { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented--sm::-webkit-scrollbar { display: none; }
@media (max-width: 640px) {
  .segmented--lg button { flex: 0 0 auto; padding: 0 14px; }
  .topbar__title { display: none; }
}
@media (min-width: 641px) {
  .segmented--lg button { padding: 0 14px; font-size: .86rem; }
  .segmented--lg small { display: none; }
}
