/* Support portal — builds on /css/styles.css variables */
.portal body, body.portal { font-size: 16px; }
.portal-main { padding: 2.2rem 0 4rem; min-height: calc(100vh - 74px); }

/* top bar */
.topbar { display: flex; align-items: center; gap: .4rem; }
.topbar a.tab {
  color: var(--muted); font-weight: 500; font-size: .93rem; padding: .5rem .85rem; border-radius: 999px;
}
.topbar a.tab:hover { color: var(--text); background: rgba(126,224,195,.08); }
.topbar a.tab.active { color: var(--ink); background: var(--mint); }
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: transparent; border: 1px solid var(--line); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--mint); }
.icon-btn svg { width: 19px; height: 19px; }
.badge-count {
  position: absolute; top: -6px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 999px; background: var(--apricot); color: var(--ink); font-size: .72rem; font-weight: 700;
  display: grid; place-items: center;
}
.dropdown { position: relative; }
.dropdown-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: min(360px, 92vw); z-index: 60;
  background: var(--ink-2); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: .5rem; display: none;
}
.dropdown.open .dropdown-panel { display: block; }
.dropdown-panel .head { display: flex; justify-content: space-between; align-items: center; padding: .5rem .7rem; font-weight: 600; font-family: var(--font-head); }
.dropdown-panel .head button { background: none; border: 0; color: var(--mint); cursor: pointer; font: inherit; font-size: .85rem; }
.notif { display: block; padding: .65rem .7rem; border-radius: 10px; color: var(--text); font-size: .9rem; }
.notif:hover { background: var(--ink-3); color: var(--text); }
.notif.unread { border-left: 3px solid var(--apricot); }
.notif small { display: block; color: var(--muted); font-size: .76rem; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; padding: .6rem .8rem; border-radius: 10px; cursor: pointer; }
.menu-item:hover { background: var(--ink-3); color: var(--text); }
.user-chip { font-size: .88rem; color: var(--muted); padding: 0 .3rem; }
.tab-icon { display: none; }
.tab-icon svg { width: 22px; height: 22px; }

/* ---------- Phone / installed app: bottom tab bar ---------- */
@media (max-width: 820px) {
  .site-header .nav { height: 60px; }
  /* A backdrop-filter on the header would trap the fixed tab bar inside it, so use a solid header on phones. */
  body.portal .site-header { padding-top: env(safe-area-inset-top); backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--ink); }
  .stats { gap: .7rem; }
  .stat { padding: .9rem 1rem; }
  .stat b { font-size: 1.6rem; }
  .portal-main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); min-height: auto; }
  .topbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    display: flex; justify-content: space-around; align-items: center; gap: 0;
    padding: .45rem .5rem calc(.45rem + env(safe-area-inset-bottom));
    background: rgba(13, 26, 30, .94); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
  }
  .topbar a.tab {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .2rem;
    padding: .35rem .2rem; border-radius: 12px; font-size: .7rem; font-weight: 500; color: var(--muted);
  }
  .topbar a.tab.active { background: transparent; color: var(--mint); }
  .topbar a.tab:hover { background: transparent; }
  .tab-icon { display: block; line-height: 0; }
  .topbar .dropdown { flex: 0 0 auto; padding: 0 .35rem; }
  .icon-btn { width: 44px; height: 44px; border: 0; background: rgba(255,255,255,.04); }
  .dropdown-panel { top: auto; bottom: calc(100% + 12px); right: 0; max-height: 65vh; overflow-y: auto; }
  .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }
  .page-head .btn { padding: .65rem 1.1rem; font-size: .92rem; }
  .auth { margin: 1.5rem auto; }
  .auth .card { padding: 1.6rem 1.3rem; }
  /* Logged-out: single "back to website" link sits in the bar */
  .topbar > a.tab:only-child { flex-direction: row; font-size: .9rem; }
}

/* Installed app: no browser chrome, so use the whole screen */
html.standalone body { overscroll-behavior-y: none; }
html.standalone .site-header .brand small { letter-spacing: .25em; }

/* Install hint */
.install-hint {
  position: fixed; left: 1rem; right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom)); z-index: 90;
  display: flex; align-items: center; gap: .8rem; max-width: 520px; margin: 0 auto;
  padding: .9rem 1rem; border-radius: 16px; background: var(--ink-3); border: 1px solid var(--line); box-shadow: var(--shadow);
  font-size: .88rem;
}
.install-hint img { border-radius: 11px; flex: none; }
.install-hint b { display: block; font-family: var(--font-head); font-size: .98rem; }
.install-hint span { color: var(--muted); }
.install-hint > div { flex: 1; }
.share-glyph { display: inline-block; vertical-align: -3px; color: var(--mint); }
.share-glyph svg { width: 16px; height: 16px; }
.install-close { background: none; border: 0; color: var(--muted); font-size: 1.4rem; cursor: pointer; padding: 0 .2rem; }
@media (max-width: 820px) { .install-hint { bottom: calc(84px + env(safe-area-inset-bottom)); } }

/* page header */
.page-head { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.6rem; }
.page-head h1 { font-size: clamp(1.7rem, 3.4vw, 2.4rem); margin: 0; }
.page-head p { margin: .3rem 0 0; color: var(--muted); }
.back { display: inline-flex; gap: .35rem; font-size: .9rem; margin-bottom: .8rem; color: var(--muted); }

/* auth card */
.auth { max-width: 440px; margin: 3rem auto; }
.auth .card { padding: 2.2rem; }
.auth .card:hover { transform: none; }
.auth h1 { font-size: 1.9rem; }
.auth .links { display: flex; justify-content: space-between; margin-top: 1rem; font-size: .9rem; }

.panel { background: var(--ink-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.panel + .panel { margin-top: 1.2rem; }
.panel h2, .panel h3 { font-size: 1.15rem; margin-bottom: .9rem; }

/* plan card */
.plan-card {
  position: relative; overflow: hidden; border-radius: 22px; padding: 1.8rem;
  border: 1px solid var(--line);
  background:
    radial-gradient(420px 200px at 100% 0%, rgba(126,224,195,.18), transparent 60%),
    radial-gradient(380px 200px at 0% 100%, rgba(255,178,122,.16), transparent 60%),
    var(--ink-3);
}
.plan-card .tier { font-family: var(--font-head); font-size: .8rem; letter-spacing: .18em; text-transform: uppercase; color: var(--mint); }
.plan-card .name { font-family: var(--font-head); font-size: 2rem; font-weight: 700; margin: .2rem 0; }
.plan-card .price { font-family: var(--font-head); font-size: 1.15rem; color: var(--apricot); font-weight: 600; }
.plan-card .price span { color: var(--muted); font-weight: 400; font-size: .9rem; }
.usage { margin-top: 1.4rem; }
.usage-row { display: flex; justify-content: space-between; font-size: .9rem; color: var(--muted); margin-bottom: .45rem; }
.usage-row b { color: var(--text); }
.bar { height: 10px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--apricot)); transition: width .6s; }
.bar.over > i { background: linear-gradient(90deg, var(--apricot), var(--danger)); }

.tiers { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.tier-card { border: 1px solid var(--line); border-radius: 16px; padding: 1.2rem 1.3rem; background: var(--ink-2); position: relative; }
.tier-card.current { border-color: var(--apricot); box-shadow: 0 0 0 3px rgba(255,178,122,.15); }
.tier-card .current-tag { position: absolute; top: -11px; right: 14px; background: var(--apricot); color: var(--ink); font-size: .7rem; font-weight: 700; padding: .15rem .6rem; border-radius: 999px; letter-spacing: .05em; }
.tier-card h3 { margin: 0 0 .3rem; font-size: 1.1rem; }
.tier-card .p { font-family: var(--font-head); color: var(--apricot); font-weight: 600; font-size: 1.3rem; }
.tier-card .p small { color: var(--muted); font-size: .8rem; font-weight: 400; }
.tier-card p { color: var(--muted); font-size: .88rem; margin: .4rem 0 0; }

.dash-grid { display: grid; grid-template-columns: 1fr 1.6fr; gap: 1.4rem; align-items: start; }
@media (max-width: 960px) { .dash-grid { grid-template-columns: 1fr; } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.6rem; }
@media (max-width: 820px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--ink-2); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem 1.2rem; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.9rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat:nth-child(1) b { color: var(--apricot); }
.stat:nth-child(2) b { color: var(--mint); }

/* filter tabs */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.filters button {
  font: inherit; font-size: .85rem; padding: .4rem .9rem; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.filters button.on { background: var(--text); color: var(--ink); border-color: var(--text); }

/* tables / lists */
.list { display: grid; gap: .6rem; }
.row-link {
  display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; align-items: center;
  padding: 1rem 1.2rem; border-radius: 14px; background: var(--ink-2); border: 1px solid var(--line); color: var(--text);
  transition: border-color .2s, transform .2s;
}
.row-link:hover { border-color: rgba(126,224,195,.5); color: var(--text); transform: translateX(2px); }
.row-link .title { font-weight: 600; }
.row-link .meta { grid-column: 1 / -1; color: var(--muted); font-size: .83rem; display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); border: 1px dashed var(--line); border-radius: 16px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th { text-align: left; font-weight: 500; color: var(--muted); font-size: .78rem; letter-spacing: .08em; text-transform: uppercase; padding: .8rem 1rem; background: var(--ink-2); }
table.data td { padding: .85rem 1rem; border-top: 1px solid var(--line); vertical-align: middle; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: rgba(126,224,195,.05); }

/* badges */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: .2rem .65rem; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.s-open { background: rgba(255,178,122,.15); color: var(--apricot); border-color: rgba(255,178,122,.35); }
.s-in_progress { background: rgba(126,224,195,.13); color: var(--mint); border-color: rgba(126,224,195,.35); }
.s-waiting { background: rgba(176,160,255,.13); color: #c4b8ff; border-color: rgba(176,160,255,.35); }
.s-closed { background: rgba(255,255,255,.05); color: var(--muted); border-color: var(--line); }
.p-urgent { background: rgba(255,138,128,.16); color: var(--danger); }
.p-high { background: rgba(255,178,122,.12); color: var(--apricot); }
.p-normal, .p-low { background: rgba(255,255,255,.05); color: var(--muted); }

/* ticket thread */
.ticket-grid { display: grid; grid-template-columns: 1fr 320px; gap: 1.4rem; align-items: start; }
@media (max-width: 960px) { .ticket-grid { grid-template-columns: 1fr; } }
.thread { display: grid; gap: 1rem; margin-bottom: 1.4rem; }
.msg { border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem 1.25rem; background: var(--ink-2); }
.msg.staff { border-left: 3px solid var(--mint); }
.msg.customer { border-left: 3px solid var(--apricot); }
.msg.internal { background: repeating-linear-gradient(135deg, rgba(196,184,255,.05) 0 10px, transparent 10px 20px), var(--ink-2); border-color: rgba(196,184,255,.35); border-left: 3px solid #c4b8ff; }
.msg header { display: flex; justify-content: space-between; gap: 1rem; font-size: .85rem; color: var(--muted); margin-bottom: .55rem; flex-wrap: wrap; }
.msg header b { color: var(--text); font-weight: 600; }
.msg .body { white-space: pre-wrap; word-wrap: break-word; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; word-break: break-word; }
.time-list { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .4rem; font-size: .88rem; }
.time-list li { display: flex; justify-content: space-between; gap: .6rem; align-items: center; padding: .45rem .6rem; background: var(--ink); border-radius: 8px; }
.time-list button { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; }
.time-list button:hover { color: var(--danger); }

.inline { display: flex; gap: .6rem; align-items: end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; flex: 1; min-width: 110px; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--mint); }
.check select { font: inherit; font-size: .88rem; color: var(--text); background: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: .45rem .7rem; }
.btn-sm { padding: .55rem 1rem; font-size: .9rem; }
.btn-danger { background: transparent; border-color: rgba(255,138,128,.45); color: var(--danger); }
.btn-danger:hover { background: rgba(255,138,128,.1); color: var(--danger); }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }

.copy-box { display: flex; gap: .5rem; margin-top: .6rem; }
.copy-box input { flex: 1; font: inherit; font-size: .85rem; color: var(--text); background: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; }

.toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 100;
  background: var(--ink-3); border: 1px solid var(--line); padding: .8rem 1.2rem; border-radius: 12px; box-shadow: var(--shadow);
  font-size: .92rem;
}
.toast.err { border-color: rgba(255,138,128,.5); color: var(--danger); }
.alert { padding: .9rem 1.1rem; border-radius: 12px; margin-bottom: 1rem; font-size: .92rem; }
.alert.err { background: rgba(255,138,128,.1); border: 1px solid rgba(255,138,128,.4); color: var(--danger); }
.alert.ok { background: rgba(126,224,195,.1); border: 1px solid rgba(126,224,195,.4); color: var(--mint); }
.hidden { display: none !important; }

/* plan change */
.cover-footer { margin-top: 1.3rem; padding-top: 1.1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .88rem; color: var(--muted); }
.tier-card { display: flex; flex-direction: column; }
.tier-action { margin-top: auto; padding-top: 1rem; }
.tier-action .btn { width: 100%; justify-content: center; }
.tier-form textarea { width: 100%; min-height: 84px; font: inherit; font-size: .9rem; color: var(--text); background: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem; margin-bottom: .6rem; resize: vertical; }
.tier-form .actions .btn { width: auto; flex: 1; }
.tier-card.requested { border-color: #c4b8ff; }
.requested-tag { background: #c4b8ff !important; }
.plan-request { border-color: rgba(255,178,122,.5); background: linear-gradient(180deg, rgba(255,178,122,.08), transparent), var(--ink-2); }
