/* TenHeavens Partner Portal */

:root {
  --brand: #E8634B;
  --brand-dark: #C24E38;
  --brand-soft: #fcebe5;
  --ink: #1b2421;
  --muted: #687570;
  --line: #e4e9e6;
  --paper: #f5f8f7;
  --surface: #ffffff;
  --ok: #1b7f4b;
  --ok-soft: #e2f6ea;
  --bad: #b5483f;
  --bad-soft: #fbe9e7;
  --pending: #9a6a12;
  --pending-soft: #fbf0d9;
  --shadow: 0 10px 34px rgba(20, 36, 33, .07);
  --radius: 18px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
code { background: var(--brand-soft); color: var(--brand-dark); padding: 1px 6px; border-radius: 6px; font-size: .9em; }

.material-symbols-rounded { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; font-size: 21px; line-height: 1; flex: none; }

h1 { margin: 0 0 8px; font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
h2 { margin: 0; font-size: 20px; font-weight: 800; }
.muted { color: var(--muted); }

/* ---------- Shell ---------- */
.portal-shell { display: flex; min-height: 100vh; }
.portal-side {
  width: 264px;
  flex: none;
  padding: 22px 16px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.portal-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 22px;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -.01em;
}
.portal-brand small { color: var(--muted); font-weight: 700; font-size: 12px; align-self: flex-end; }
.portal-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 900;
}
.brand-logo { height: 26px; width: auto; display: block; }
.portal-side nav { display: grid; gap: 4px; }
.portal-side nav a {
  display: flex;
  align-items: center;
  gap: 13px;
  height: 50px;
  padding: 0 16px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 15px;
}
.portal-side nav a:hover { background: var(--paper); color: var(--ink); }
.portal-side nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.portal-side nav a.active .material-symbols-rounded { color: var(--brand); font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.portal-logout { margin-top: 8px; }

.portal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 68px;
  padding: 0 clamp(20px, 4vw, 40px);
  background: rgba(245, 248, 247, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-lead { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.user-chip { display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 14px 0 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.user-avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; font-weight: 800; }
.portal-content { padding: clamp(22px, 4vw, 40px); }

/* ---------- Page hero ---------- */
.page-hero { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 18px; margin-bottom: 26px; }
.page-hero p { margin: 0; }

/* ---------- Metrics ---------- */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 26px; }
.metric { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.metric-icon { display: grid; place-items: center; width: 50px; height: 50px; flex: none; border-radius: 14px; background: var(--paper); color: var(--muted); }
.metric-icon .material-symbols-rounded { font-size: 25px; }
.metric-label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); }
.metric-value { display: block; margin-top: 2px; font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.metric.tone-primary .metric-icon { background: var(--brand-soft); color: var(--brand); }
.metric.tone-primary .metric-value { color: var(--brand-dark); }
.metric.tone-ok .metric-icon { background: var(--ok-soft); color: var(--ok); }
.metric.tone-pending .metric-icon { background: var(--pending-soft); color: var(--pending); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.section-title { display: flex; align-items: center; gap: 9px; font-size: 18px; }
.section-title .material-symbols-rounded { color: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:hover { background: var(--brand-dark); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn .material-symbols-rounded { font-size: 20px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--paper); box-shadow: none; }

/* ---------- Forms ---------- */
.form-card { padding: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
label { display: grid; gap: 8px; font-weight: 700; font-size: 14px; color: var(--ink); }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  font-weight: 500;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(232, 99, 75, .14); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.form-actions { display: flex; gap: 12px; margin-top: 22px; }
.field-hint { font-size: 12px; font-weight: 600; color: var(--muted); }
input[type="file"] {
  padding: 10px 12px;
  cursor: pointer;
  background: var(--paper);
}
input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Tables ---------- */
.table-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.table-search { width: min(320px, 100%); min-height: 44px; padding: 10px 16px; border-radius: 999px; }
.table-count { margin-left: auto; font-size: 13px; font-weight: 700; white-space: nowrap; }
.table-scroll { max-height: 72vh; overflow: auto; border: 1px solid var(--line); border-radius: 14px; -webkit-overflow-scrolling: touch; }
table.data-table { width: 100%; border-collapse: collapse; min-width: 560px; background: var(--surface); }
.data-table th, .data-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table thead th { position: sticky; top: 0; z-index: 1; background: var(--paper); font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(232, 99, 75, .04); }
.note { font-style: italic; }
.s-thumb { display: block; width: 56px; height: 40px; border-radius: 8px; background: var(--brand-soft) center / cover no-repeat; }

/* ---------- Tags / status ---------- */
.tag { display: inline-flex; align-items: center; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 800; text-transform: capitalize; background: var(--brand-soft); color: var(--brand-dark); }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.pending { background: var(--pending-soft); color: var(--pending); }
.tag.soft { background: var(--paper); color: var(--muted); }

/* ---------- Saved place cards ---------- */
.place-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.place-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.place-thumb { aspect-ratio: 3 / 2; background: var(--brand-soft) center / cover no-repeat; }
.place-body { display: grid; gap: 6px; padding: 16px; }
.place-body strong { font-size: 16px; }
.place-body .tag { justify-self: start; }

.card.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 56px 24px; }
.card.empty .material-symbols-rounded { font-size: 40px; color: var(--brand); }
.card.empty h2 { margin: 0; }

/* ---------- Flash ---------- */
.flash { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); }
.flash.success { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

/* ---------- Auth ---------- */
.portal-auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 0%, rgba(232, 99, 75, .14), transparent 32rem),
    radial-gradient(circle at 100% 100%, rgba(232, 99, 75, .10), transparent 30rem),
    var(--paper);
}
.portal-auth { width: min(440px, 100%); }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 36px 32px; box-shadow: 0 24px 70px rgba(20, 36, 33, .12); }
.auth-brand { display: flex; align-items: center; gap: 12px; font-weight: 900; font-size: 19px; margin-bottom: 22px; }
.auth-logo { height: 30px; width: auto; }
.auth-brand-tag { color: var(--muted); font-weight: 700; font-size: 13px; border-left: 1px solid var(--line); padding-left: 12px; }
.auth-card h1 { font-size: 26px; }
.auth-card > p { margin: 0 0 22px; }
.auth-form { display: grid; gap: 16px; }
.auth-form button { margin-top: 6px; }
.auth-switch { margin: 22px 0 0; color: var(--muted); font-weight: 600; }
.auth-switch a { color: var(--brand-dark); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.auth-form .optional { color: var(--muted); font-weight: 600; font-size: 12px; }
.auth-success { display: grid; justify-items: center; text-align: center; gap: 10px; }
.auth-success .material-symbols-rounded { font-size: 46px; color: var(--brand); }
.auth-success h1 { margin: 0; }
.auth-success p { margin: 0 0 8px; }
.debug-link { background: var(--brand-soft); padding: 10px 14px; border-radius: 12px; word-break: break-all; }
.debug-link a { color: var(--brand-dark); font-weight: 700; }
.debug-note { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--paper); padding: 8px 12px; border-radius: 10px; }

@media (max-width: 860px) {
  .portal-shell { display: block; }
  .portal-side { width: 100%; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--line); }
  .portal-side nav { grid-auto-flow: column; overflow-x: auto; }
  .portal-side nav a { white-space: nowrap; }
  .form-grid { grid-template-columns: 1fr; }
  .table-search { width: 100%; }
  .table-count { margin-left: 0; }
}
