/* AZWebCorp theme (colours and type taken from azwebcorp.com) */
:root {
  --azw-ink: #111823;          /* near-black navy */
  --azw-ink-2: #161208;        /* warm black, text on gold */
  --azw-bronze: #30240a;       /* gradient end */
  --azw-gold: #e6b84d;         /* brand gold */
  --azw-gold-soft: #f5d47d;
  --azw-gold-dark: #8a6512;    /* gold for text/links on light backgrounds (AA contrast) */
  --azw-primary: var(--azw-gold);
  --azw-primary-hover: #d9a93a;
  --azw-primary-contrast: var(--azw-ink-2);
  --azw-bg: #f6f5f1;
  --azw-surface: #ffffff;
  --azw-text: #111820;
  --azw-muted: #5d6875;
  --azw-border: #e1ddd2;
  --azw-selected-bg: #fdf6e3;
  --azw-error: #b42318;
  --azw-warning-bg: #fff6e5;
  --azw-warning-border: #f0c36d;
  --azw-notice-bg: #eef7f0;
  --azw-notice-border: #9fd3ae;
  --azw-radius: 12px;
  --azw-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --azw-heading: "Poppins", "Inter", system-ui, sans-serif;
  --azw-hero: linear-gradient(120deg, #111823 0%, #30240a 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--azw-bg); color: var(--azw-text); font-family: var(--azw-font); font-size: 16px; line-height: 1.55; }
h1, h2, h3, h4 { font-family: var(--azw-heading); font-weight: 600; letter-spacing: -0.01em; }
[hidden] { display: none !important; }
a { color: var(--azw-gold-dark); }

/* ---------- shared controls ---------- */
.btn {
  font: inherit; font-weight: 700; min-height: 48px; padding: 0 22px; border-radius: 11px;
  border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn-primary { background: var(--azw-gold); color: var(--azw-ink-2); border-color: var(--azw-gold); }
.btn-primary:hover { background: var(--azw-primary-hover); border-color: var(--azw-primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-secondary { background: var(--azw-surface); color: var(--azw-text); border-color: var(--azw-border); }
.btn-secondary:hover { border-color: var(--azw-gold); }
.btn-dark { background: var(--azw-ink); color: #fff; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 0.9rem; }
.btn-danger { background: var(--azw-surface); color: var(--azw-error); border-color: var(--azw-border); }
.btn:focus-visible, .tab:focus-visible, .pkg:focus-visible { outline: 3px solid color-mix(in srgb, var(--azw-gold) 60%, transparent); outline-offset: 2px; }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--azw-gold-dark); text-decoration: underline; cursor: pointer; }

.field { margin: 0 0 14px; }
.field label { display: block; font-weight: 600; margin: 0 0 6px; }
.optional { font-weight: 400; color: var(--azw-muted); }
.hint { color: var(--azw-muted); font-size: 0.9rem; margin: 4px 0 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--azw-text); background: var(--azw-surface);
  border: 1.5px solid var(--azw-border); border-radius: 10px; padding: 11px 13px; min-height: 48px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--azw-gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--azw-gold) 25%, transparent); }
[aria-invalid="true"] { border-color: var(--azw-error) !important; }
.error { color: var(--azw-error); font-size: 0.9rem; margin: 6px 0 0; }
.error:empty { display: none; }
.form-error { color: var(--azw-error); margin: 10px 0 0; }
.form-error:empty { display: none; }

.notice { padding: 12px 14px; border-radius: 10px; background: var(--azw-notice-bg); border: 1px solid var(--azw-notice-border); }
.warning { padding: 12px 14px; border-radius: 10px; background: var(--azw-warning-bg); border: 1px solid var(--azw-warning-border); }
.notice p, .warning p { margin: 0; }

.card { background: var(--azw-surface); border: 1px solid var(--azw-border); border-radius: 14px; padding: 20px; }

.logo { display: block; height: 34px; width: auto; }

/* ---------- auth / invite pages ---------- */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--azw-hero); }
.auth .card { width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35); }
.auth .auth-logo { display: flex; justify-content: center; margin-bottom: 22px; }
.auth .auth-logo img { height: 46px; width: auto; }
.auth h1 { font-size: 1.45rem; margin: 0 0 4px; }
.auth .sub { color: var(--azw-muted); margin: 0 0 18px; }
.auth .btn-primary { width: 100%; margin-top: 6px; }
.auth .switch { text-align: center; margin: 16px 0 0; color: var(--azw-muted); font-size: 0.92rem; }
.auth .tagline { color: #d6dce4; text-align: center; margin-top: 18px; font-size: 0.9rem; }

/* ---------- portal layout ---------- */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--azw-hero); color: #fff; }
.topbar .who { margin-left: auto; color: #d6dce4; font-size: 0.9rem; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .balance-pill {
  font-weight: 700; font-size: 0.85rem; color: var(--azw-ink-2); background: var(--azw-gold);
  padding: 4px 10px; border-radius: 99px; white-space: nowrap; border: 0; cursor: pointer; font-family: inherit;
}
.topbar .balance-pill.is-low { background: #f3c9c4; }
.topbar .btn-secondary { background: transparent; color: #fff; border-color: rgba(230, 184, 77, 0.5); }
.tabs { display: flex; gap: 4px; padding: 0 12px; background: var(--azw-surface); border-bottom: 1px solid var(--azw-border); overflow-x: auto; }
.tab {
  font: inherit; font-weight: 600; color: var(--azw-muted); background: none; border: 0; cursor: pointer;
  padding: 12px 14px; border-bottom: 3px solid transparent; white-space: nowrap; min-height: 48px;
}
.tab[aria-selected="true"] { color: var(--azw-ink); border-bottom-color: var(--azw-gold); }
.tab .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--azw-gold); margin-left: 6px; vertical-align: middle; }
.panel { flex: 1; min-height: 0; }
.panel-scroll { height: 100%; overflow-y: auto; }
.wrap { max-width: 820px; margin: 0 auto; padding: 16px; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; }
.messages { flex: 1; overflow-y: auto; padding: 16px; }
.messages-inner { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--azw-ink); color: #fff; border-bottom-right-radius: 4px; }
.msg.user a { color: var(--azw-gold-soft); }
.msg.assistant { align-self: flex-start; background: var(--azw-surface); border: 1px solid var(--azw-border); border-bottom-left-radius: 4px; }
.msg.pending::after { content: "..."; color: var(--azw-muted); }
.msg.rich { white-space: normal; }
.msg.rich p { margin: 0 0 0.6em; }
.msg.rich p:last-child, .msg.rich ul:last-child, .msg.rich ol:last-child { margin-bottom: 0; }
.msg.rich ul, .msg.rich ol { margin: 0 0 0.6em; padding-left: 1.3em; }
.msg.rich li { margin: 0.2em 0; }
.msg.rich .rich-head { font-weight: 700; margin-top: 0.4em; }
.msg.rich code { font: 0.88em ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--azw-bg); border: 1px solid var(--azw-border); border-radius: 4px; padding: 0 4px; word-break: break-word; }
.msg.failed { opacity: 0.6; }
.welcome { color: var(--azw-muted); text-align: center; padding: 24px 8px; }
.welcome h2 { color: var(--azw-text); margin: 0 0 6px; font-size: 1.25rem; }
.site-card { border-bottom: 1px solid var(--azw-border); background: var(--azw-selected-bg); padding: 10px 16px; }
.site-card-inner { max-width: 760px; margin: 0 auto; }
.site-head { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.site-title { margin: 0; font-weight: 700; }
.site-status { margin: 2px 0 0; color: var(--azw-muted); font-size: 0.92rem; }
.site-status.busy::before { content: ""; display: inline-block; width: 0.8em; height: 0.8em; margin-right: 6px; vertical-align: -1px; border: 2px solid var(--azw-gold-dark); border-right-color: transparent; border-radius: 50%; animation: site-spin 0.8s linear infinite; }
@keyframes site-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .site-status.busy::before { animation: none; } }
.site-actions { display: flex; gap: 8px; }
.site-change { display: flex; gap: 8px; margin-top: 8px; }
.site-change input { flex: 1; min-width: 0; }
.site-card .form-error:empty { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.composer { border-top: 1px solid var(--azw-border); background: var(--azw-surface); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
.composer-inner { max-width: 760px; margin: 0 auto; }
.composer form { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 48px; max-height: 180px; resize: none; }
.composer .warning { margin-bottom: 8px; }
.composer .warning .btn { margin-top: 8px; }
.composer-meta { display: flex; justify-content: space-between; gap: 8px; color: var(--azw-muted); font-size: 0.8rem; margin-top: 6px; }

/* ---------- questionnaire ---------- */
.intake-frame { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- secure uploads + billing ---------- */
.uploads h2, .billing h2 { font-size: 1.25rem; margin: 0 0 6px; }
.uploads .lead, .billing .lead { color: var(--azw-muted); margin: 0 0 16px; }
.uploads .card, .billing .card { margin-bottom: 16px; }
.row { display: grid; gap: 0 12px; }
@media (min-width: 640px) { .row { grid-template-columns: 1fr 1fr; } }
.secret-wrap { display: flex; gap: 8px; }
.secret-wrap input { flex: 1; }
.cred-list { list-style: none; margin: 0; padding: 0; }
.cred-list li { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--azw-border); flex-wrap: wrap; }
.cred-list li:last-child { border-bottom: 0; }
.cred-main { flex: 1; min-width: 200px; }
.cred-main b { display: block; }
.cred-main span { color: var(--azw-muted); font-size: 0.9rem; }
.lock { font-size: 0.75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--azw-selected-bg); border: 1px solid var(--azw-gold); white-space: nowrap; }
.empty { color: var(--azw-muted); margin: 0; }

.balance-card { background: var(--azw-hero); color: #fff; border: 0; }
.balance-card .label { color: #d6dce4; margin: 0; font-size: 0.9rem; }
.balance-card .amount { font-family: var(--azw-heading); font-size: 2.4rem; font-weight: 700; color: var(--azw-gold); margin: 2px 0 6px; }
.balance-card .status { margin: 0; color: #d6dce4; font-size: 0.92rem; }
.packages { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; margin: 12px 0; }
.pkg {
  font: inherit; font-weight: 700; font-size: 1.15rem; min-height: 64px; border-radius: 12px; cursor: pointer;
  background: var(--azw-surface); color: var(--azw-text); border: 1.5px solid var(--azw-border);
}
.pkg:hover { border-color: var(--azw-gold); }
.pkg.is-selected { border-color: var(--azw-gold); background: var(--azw-selected-bg); }
.custom-amount { display: flex; gap: 8px; align-items: center; }
.custom-amount input { max-width: 160px; }
#checkout { margin-top: 14px; }
.ledger { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.ledger th, .ledger td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--azw-border); }
.ledger th { color: var(--azw-muted); font-weight: 600; }
.ledger td.num, .ledger th.num { text-align: right; white-space: nowrap; }
.ledger .plus { color: #1b7a3a; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 10;
  background: var(--azw-ink); color: #fff; padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px);
  border-left: 4px solid var(--azw-gold);
}

/* ---------- admin ---------- */
.admin .wrap { max-width: 1100px; }
.admin .client { margin-bottom: 14px; }
.admin .client h3 { margin: 0; }
.admin .client .meta { color: var(--azw-muted); font-size: 0.9rem; margin: 2px 0 10px; }
.admin .actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; align-items: center; }
.admin pre { background: var(--azw-bg); border: 1px solid var(--azw-border); border-radius: 8px; padding: 10px; overflow: auto; max-height: 420px; white-space: pre-wrap; word-break: break-word; }
.admin .reveal { margin-top: 8px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--azw-surface); border: 1px solid var(--azw-border); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-family: var(--azw-heading); font-size: 1.35rem; }
.stat span { color: var(--azw-muted); font-size: 0.85rem; }
.badge { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--azw-bg); border: 1px solid var(--azw-border); }
.badge.pending { border-color: var(--azw-gold); background: var(--azw-selected-bg); }
.badge.suspended { border-color: var(--azw-error); color: var(--azw-error); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin: 0; flex: 1; min-width: 160px; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- developer tab ---------- */
.dev-intro { background: var(--azw-surface); border: 1px solid var(--azw-border); border-radius: var(--azw-radius); padding: 18px 20px; }
.dev-intro h2 { margin: 0 0 8px; font-size: 1.2rem; }
.dev-intro p { margin: 0 0 8px; color: var(--azw-muted); }
.dev-intro p:last-child { margin-bottom: 0; }
.msg.notice { align-self: center; max-width: 92%; background: var(--azw-notice-bg); border: 1px solid var(--azw-notice-border); font-size: 0.95rem; }
.msg.error { align-self: center; max-width: 92%; background: #fdecea; border: 1px solid #f3b4ae; color: var(--azw-error); font-size: 0.95rem; }
.tool-card { align-self: stretch; background: var(--azw-surface); border: 1px solid var(--azw-border); border-left: 4px solid var(--azw-gold); border-radius: 10px; padding: 10px 14px; }
.tool-title { font-weight: 700; font-size: 0.95rem; word-break: break-all; }
.tool-detail, .tool-output pre { margin: 8px 0 0; padding: 10px 12px; background: var(--azw-ink); color: #f1efe8; border-radius: 8px; font: 0.85rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto; }
.tool-status { margin-top: 8px; font-size: 0.85rem; font-weight: 600; color: var(--azw-muted); }
.tool-status.perm-ask { color: var(--azw-gold-dark); }
.tool-status.perm-deny { color: var(--azw-error); }
.tool-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.tool-actions:empty { display: none; }
.tool-actions .deny-note { flex: 1 1 260px; min-height: 40px; padding: 0 12px; border: 1px solid var(--azw-border); border-radius: 10px; font: inherit; font-size: 0.9rem; }
.tool-output { margin-top: 8px; font-size: 0.9rem; }
.tool-output summary { cursor: pointer; color: var(--azw-gold-dark); font-weight: 600; }
.tool-output.is-error summary { color: var(--azw-error); }
.dev-status { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 8px; border-radius: 10px; background: var(--azw-selected-bg); border: 1px solid var(--azw-warning-border); font-weight: 600; }
.dev-status #dev-status-text { flex: 1; }
.dev-status.is-waiting { background: var(--azw-warning-bg); }
.dev-status.is-waiting .spinner { display: none; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--azw-gold); border-right-color: transparent; animation: azw-spin 0.8s linear infinite; }
@keyframes azw-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--azw-gold-dark); }
.check .hint { font-weight: 400; color: var(--azw-muted); }
.check.small { margin: 0; font-size: 0.85rem; white-space: nowrap; }
/* attachments, images, toolbar */
.attach-btn { flex-shrink: 0; width: 48px; min-height: 48px; padding: 0; font-size: 1.4rem; line-height: 1; }
.dev-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.dev-attachments[hidden] { display: none; }
.attach-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 240px; padding: 4px 6px 4px 8px; border: 1px solid var(--azw-border); border-radius: 99px; background: var(--azw-bg); font-size: 0.85rem; }
.attach-chip img { width: 24px; height: 24px; object-fit: cover; border-radius: 4px; }
.attach-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-remove { border: 0; background: none; font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--azw-muted); padding: 0 4px; }
.attach-remove:hover { color: var(--azw-error); }
.dev-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.dev-images img { display: block; max-width: 220px; max-height: 160px; border-radius: 8px; border: 1px solid var(--azw-border); background: #fff; }
.dev-file-list { margin-top: 6px; font-size: 0.85rem; opacity: 0.85; }
.dev-tools { flex-wrap: wrap; }
.dev-tool-buttons { display: flex; flex-wrap: wrap; gap: 4px 14px; }
#panel-developer.is-dropping .composer { outline: 2px dashed var(--azw-gold); outline-offset: -6px; }

/* dialog: Files, Preview, Project notes */
.dev-dialog { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 64px); padding: 0; border: 1px solid var(--azw-border); border-radius: var(--azw-radius); background: var(--azw-surface); color: inherit; }
.dev-dialog::backdrop { background: rgba(17, 24, 39, 0.45); }
.dev-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--azw-border); position: sticky; top: 0; background: var(--azw-surface); }
.dev-dialog-head h2 { margin: 0; font-size: 1.15rem; }
.dev-dialog-body { padding: 14px 18px 18px; }
.dev-dialog-body .muted { color: var(--azw-muted); margin: 0 0 12px; font-size: 0.92rem; }
.files-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.crumbs { font-weight: 600; word-break: break-all; }
.file-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--azw-border); border-radius: 10px; }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--azw-border); }
.file-item:first-child { border-top: 0; }
.file-item .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.file-item.is-folder .file-name { font-weight: 600; }
.file-meta { color: var(--azw-muted); font-size: 0.85rem; white-space: nowrap; }
.preview-current, .preview-update { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.preview-current .btn { text-decoration: none; }
.preview-update select { min-height: 44px; padding: 0 10px; border: 1px solid var(--azw-border); border-radius: 10px; font: inherit; min-width: 180px; }
.notes-text { width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--azw-border); border-radius: 10px; margin-bottom: 8px; resize: vertical; box-sizing: border-box; }
@media (max-width: 560px) {
  .composer-meta.dev-tools > span:last-child { display: none; }
  .dev-images img { max-width: 140px; }
}

.dev-note { margin: 6px 0 0; padding: 8px 12px; border-radius: 10px; background: var(--azw-notice-bg); border: 1px solid var(--azw-notice-border); font-size: 0.9rem; }
.topbar .btn, .topbar .balance-pill { white-space: nowrap; flex-shrink: 0; }
.topbar .back-link { text-decoration: none; }
.topbar .back-link[hidden] { display: none; }
.tabs .tab { white-space: nowrap; flex-shrink: 0; }
@media (max-width: 560px) {
  .topbar .who { display: none; }
  .topbar .balance-pill { margin-left: auto; }
  .topbar .logo { height: 26px; width: auto; }
}
