/* Shared shell for the Aquaivo account dashboards (customer, operator, admin)
   and the auth page. Builds on styles.css tokens. */

.dash-body { background: var(--cream); min-height: 100vh; }

/* ---- top bar ---- */
.dash-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 16px;
  padding: 14px max(20px, calc((100vw - 1240px) / 2));
  background: rgba(246, 242, 233, 0.9);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.dash-top .brand { font-size: 22px; }
.dash-top .dash-context { font-size: 12px; color: var(--muted); border-left: 1px solid var(--line); padding-left: 16px; }
.dash-top .dash-user { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.dash-top .dash-user .avatar {
  width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
  background: var(--ink); color: #fff; display: grid; place-items: center; font: 600 12px "DM Sans", sans-serif;
}
.dash-top .dash-user button, .dash-top .dash-user a.linkish {
  border: 0; background: none; color: var(--orange-deep); font: 600 13px "DM Sans", sans-serif; cursor: pointer; text-decoration: none;
}
.demo-pill {
  font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase;
  background: #eef3ef; color: #4c6b60; border-radius: 20px; padding: 4px 9px;
}

/* ---- layout ---- */
.dash-shell {
  max-width: 1240px; margin: 0 auto; padding: 26px 20px 80px;
  display: grid; grid-template-columns: 218px 1fr; gap: 28px; align-items: start;
}
.dash-nav { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 3px; }
.dash-nav a, .dash-nav button {
  text-align: left; border: 0; background: none; cursor: pointer;
  padding: 10px 12px; border-radius: 9px; font: 500 13.5px "DM Sans", sans-serif; color: #4b6360;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.dash-nav a:hover, .dash-nav button:hover { background: rgba(7, 48, 47, 0.05); }
.dash-nav a[aria-current="page"], .dash-nav .is-active { background: var(--ink); color: #fff; font-weight: 600; }
.dash-nav .count { font-size: 11px; background: var(--orange); color: #fff; border-radius: 20px; padding: 1px 7px; }
.dash-nav a[aria-current="page"] .count, .dash-nav .is-active .count { background: rgba(255,255,255,0.25); }

.dash-main { min-width: 0; }
.dash-head { margin-bottom: 22px; }
.dash-head h1 { font: 700 clamp(28px, 4vw, 40px) Fraunces, serif; letter-spacing: -1.6px; margin: 0 0 4px; }
.dash-head p { color: var(--muted); margin: 0; font-size: 14px; }

.panel {
  background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.panel > h2 { font: 600 19px Fraunces, serif; letter-spacing: -0.4px; margin: 0 0 14px; }
.panel > h2.with-action { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel .sub { font-size: 13px; color: var(--muted); margin: -8px 0 14px; }

/* ---- stat tiles ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
  background: var(--paper); border: 1px solid var(--line-soft); border-radius: 13px; padding: 15px 16px;
}
.stat span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #7d8c8c; }
.stat strong { display: block; font: 600 24px Fraunces, serif; margin: 6px 0 3px; }
.stat small { font-size: 11px; color: var(--muted); }

/* ---- tabs ---- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--line-soft); }
.tabs button {
  border: 0; background: none; cursor: pointer; padding: 9px 12px; font: 600 13px "DM Sans", sans-serif;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--orange); }
.tabs button .count { font-size: 11px; color: var(--muted); }

/* ---- forms ---- */
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label, .field .label { font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: #5f7473; }
.field input, .field select, .field textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 11px 12px;
  font: 400 14px "DM Sans", sans-serif; background: #fff; color: var(--ink); width: 100%;
}
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--orange); outline-offset: 1px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-hint { font-size: 11px; color: var(--muted); }
.checks { display: grid; gap: 8px; }
.checks label { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0; cursor: pointer; }
.checks input { width: 16px; height: 16px; accent-color: var(--orange); }
fieldset.field-set { border: 0; padding: 0; margin: 0 0 8px; }
fieldset.field-set legend { font-size: 11px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; color: #5f7473; padding: 0; margin-bottom: 8px; }

.form-error { color: #b23c1e; font-size: 13px; margin: 4px 0 12px; min-height: 1em; }
.form-ok { color: #2f7458; font-size: 13px; margin: 4px 0 12px; }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 7px; border: 0; cursor: pointer; font: 600 13px "DM Sans", sans-serif; border-radius: 9px; padding: 10px 16px; transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease); }
.btn-primary { background: linear-gradient(150deg, var(--orange), var(--orange-deep)); color: #fff; box-shadow: 0 8px 20px rgba(242,107,62,0.24); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: #fff; color: #b23c1e; border: 1px solid #e9cfc6; }
.btn-small { padding: 7px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ---- cards / lists ---- */
.record {
  border: 1px solid var(--line-soft); border-radius: 12px; padding: 16px; margin-bottom: 12px; background: var(--paper);
}
.record .rec-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.record h3 { font: 600 16px Fraunces, serif; margin: 0; letter-spacing: -0.3px; }
.record .rec-sub { font-size: 12px; color: var(--muted); margin: 3px 0 0; }
.rec-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 14px 0; padding: 12px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.rec-facts div span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.4px; color: #7d8c8c; }
.rec-facts div strong { font-size: 13px; font-weight: 600; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.badge { font-size: 10px; font-weight: 700; letter-spacing: 0.4px; text-transform: uppercase; padding: 5px 9px; border-radius: 20px; white-space: nowrap; }
.badge.green { background: #dff0e6; color: #2f7458; }
.badge.amber { background: #fdeecb; color: #97701f; }
.badge.blue { background: #dcebf5; color: #2c6488; }
.badge.grey { background: #e9ecea; color: #5f7473; }
.badge.red { background: #f7e0d9; color: #a4482c; }

/* ---- data table ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { text-align: left; font: 700 10px "DM Sans", sans-serif; letter-spacing: 0.5px; text-transform: uppercase; color: #829391; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 12px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.data-table tr:last-child td { border-bottom: 0; }
.table-scroll { overflow-x: auto; }

/* ---- states ---- */
.state { text-align: center; padding: 40px 20px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); }
.state h3 { font: 600 18px Fraunces, serif; margin: 0 0 6px; color: var(--ink); }
.state p { font-size: 13px; margin: 0 0 14px; }
.state.error { border-color: #eccabd; background: #f9e7e1; color: #7c3b25; }
.state.error h3 { color: #a4482c; }
.skeleton { height: 90px; border-radius: 12px; margin-bottom: 12px; background: linear-gradient(100deg, #eef1ee 30%, #f6f8f5 50%, #eef1ee 70%); background-size: 200% 100%; animation: dsk 1.3s ease-in-out infinite; }
@keyframes dsk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 22px; z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow-md); max-width: 90vw;
}
.toast.err { background: #a4482c; }
.toast[hidden] { display: none; }

/* ---- modal ---- */
.dm { position: fixed; inset: 0; background: rgba(4,33,31,0.6); backdrop-filter: blur(3px); z-index: 70; display: grid; place-items: center; padding: 18px; }
.dm[hidden] { display: none; }
.dm-panel { background: var(--paper); border-radius: var(--radius-lg); padding: 28px; width: min(520px, 100%); box-shadow: var(--shadow-md); max-height: 88vh; overflow-y: auto; }
.dm-panel h2 { font: 600 22px Fraunces, serif; letter-spacing: -0.5px; margin: 0 0 6px; }
.dm-close { position: absolute; }

/* ---- auth page ---- */
.auth-wrap { max-width: 460px; margin: 60px auto; padding: 0 20px; }
.auth-card { background: var(--paper); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 34px; box-shadow: var(--shadow-md); }
.auth-card h1 { font: 700 30px Fraunces, serif; letter-spacing: -1.4px; margin: 0 0 6px; }
.auth-card > p { color: var(--muted); font-size: 14px; margin: 0 0 22px; }
.auth-toggle { display: flex; gap: 4px; background: #eef1ee; border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.auth-toggle button { flex: 1; border: 0; background: none; cursor: pointer; padding: 9px; border-radius: 7px; font: 600 13px "DM Sans", sans-serif; color: var(--muted); }
.auth-toggle button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.auth-alt { text-align: center; font-size: 13px; margin-top: 16px; color: var(--muted); }
.auth-alt button { border: 0; background: none; color: var(--orange-deep); font-weight: 600; cursor: pointer; font-size: 13px; }
.auth-note { font-size: 11px; color: var(--muted); line-height: 1.5; margin-top: 14px; }
.role-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.role-picker label { border: 1px solid var(--line); border-radius: 11px; padding: 12px; cursor: pointer; font-size: 13px; }
.role-picker label:has(input:checked) { border-color: var(--orange); background: #fdf1ea; }
.role-picker input { position: absolute; opacity: 0; }
.role-picker strong { display: block; font-weight: 600; }
.role-picker span { font-size: 11px; color: var(--muted); }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .dash-shell { grid-template-columns: 1fr; gap: 14px; }
  .dash-nav {
    position: static; flex-direction: row; overflow-x: auto; gap: 6px;
    padding-bottom: 6px; border-bottom: 1px solid var(--line-soft);
  }
  .dash-nav a, .dash-nav button { white-space: nowrap; }
  .dash-nav a[aria-current="page"], .dash-nav .is-active { }
  .field-row { grid-template-columns: 1fr; }
  .dash-top .dash-context { display: none; }
}

/* ---- profile photo / logo ---- */
.profile-photo-row { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.avatar-lg {
  width: 72px; height: 72px; border-radius: 50%; flex: none;
  background: var(--line-soft); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display, inherit); font-size: 26px; font-weight: 700;
  overflow: hidden;
}
.avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.profile-photo-row .field-hint { margin-top: 6px; }

/* ---- agreement acceptance line ---- */
.agree-line { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; line-height: 1.45; margin-top: 10px; }
.agree-line input { margin-top: 2px; flex: none; }
