/* Appjesite dashboard. Phone first: most owners use it on their phone. */
:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #5d6470;
  --line: #e5e1da;
  --soft: #efece6;
  --brand: #c93a17;
  --brand-dark: #a92f12;
  --brand-soft: #fbebe5;
  --ok: #1d7a4c;
  --ok-soft: #e3f3ea;
  --warn: #8a5a00;
  --warn-soft: #fff1d6;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px #16181d0d, 0 4px 16px #16181d0a;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 18px; line-height: 1.3; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #c93a1755; outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.stack > * + * { margin-top: 14px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 60px; padding: 0 20px; background: #f6f4f0ee; backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 750; font-size: 19px; letter-spacing: -0.02em; text-decoration: none; }
.brand .mark { width: 30px; height: 30px; color: var(--brand); }
.topnav { display: flex; align-items: center; gap: 18px; font-size: 15px; white-space: nowrap; }
.topnav a { color: var(--ink); text-decoration: none; }
.topnav a:hover { color: var(--brand); }
.topnav form { margin: 0; }
.linklike { padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.linklike:hover { color: var(--brand); }

/* buttons, fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border: 1px solid transparent; border-radius: 10px; font-weight: 650; font-size: 15px; text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.big { width: 100%; min-height: 52px; font-size: 16px; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: .55; cursor: default; }
.field { display: block; }
.field > span { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 600; }
.field small { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 12px; background: #fff; border: 1px solid #d6d1c8; border-radius: 10px; }
textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #c93a1726; }
input.code { font-size: 28px; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; }
.invalid input, .invalid textarea, .invalid select, input.invalid { border-color: var(--danger); }
.field-error { margin-top: 4px; color: var(--danger); font-size: 13px; font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.alert { padding: 10px 14px; border-radius: 10px; background: #fdecea; color: var(--danger); font-weight: 600; }
.note { padding: 10px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 99px; background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 650; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* simple pages */
.center { display: grid; place-items: center; min-height: calc(100vh - 60px); padding: 24px 16px; }
.auth { width: 100%; max-width: 420px; }
.auth h1 { margin-bottom: 8px; }
.auth .muted { margin-bottom: 18px; }
.auth .alert, .auth .note { margin-bottom: 14px; }
.again { margin-top: 14px; text-align: center; }
.page { max-width: 960px; margin: 0 auto; padding: 28px 16px 60px; }
.page > h1 { margin-bottom: 20px; }
.page > .card + .card { margin-top: 18px; }
.site-list { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.site-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.site-card h2 { font-size: 20px; }
.site-card p + p { margin-top: 8px; }
.list { margin: 14px 0 0; padding: 0; list-style: none; }
.list > li { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.list > li p { margin-top: 4px; }
.list.compact > li { padding: 8px 0; }
.table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 15px; }
.table th, .table td { padding: 10px 8px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 13px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; align-items: end; margin-top: 14px; }

/* workspace: panel (chat, editor, history) next to a live preview */
.draftbar { position: sticky; top: 60px; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; padding: 10px 20px; background: var(--warn-soft); border-bottom: 1px solid #f0d9a8; color: #5c3d00; }
.workspace { display: grid; grid-template-columns: minmax(360px, 460px) 1fr; height: calc(100vh - 60px); }
.draftbar:not([hidden]) + .workspace { height: calc(100vh - 60px - 57px); }
.panel { display: flex; flex-direction: column; min-height: 0; background: var(--card); border-right: 1px solid var(--line); }
.panel-head { padding: 18px 20px 6px; }
.panel-head h1 { font-size: 22px; }
.small-link { font-size: 14px; text-decoration: none; }
.small-link:hover { color: var(--brand); }
.tabs { display: flex; gap: 4px; padding: 10px 14px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { flex: none; padding: 10px 12px; white-space: nowrap; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--muted); font-weight: 650; font-size: 15px; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--brand); }
.only-mobile { display: none; }
.tabpanel { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.chat { flex: 1; overflow-y: auto; margin: 0; padding: 18px 16px; list-style: none; display: flex; flex-direction: column; gap: 10px; }
.chat li { max-width: 88%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
.chat .user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.chat .assistant { align-self: flex-start; background: var(--soft); border-bottom-left-radius: 5px; }
.chat .assistant .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; white-space: normal; }
.chat .typing { color: var(--muted); }
.chat .typing::after { content: "…"; animation: dots 1.2s steps(4) infinite; display: inline-block; width: 1.2em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.2em; } }
.chat .intro { align-self: stretch; max-width: none; background: none; padding: 4px 2px 8px; color: var(--muted); }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.chip { padding: 7px 12px; border: 1px solid var(--line); border-radius: 99px; background: #fff; font-size: 14px; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px 14px 14px; border-top: 1px solid var(--line); background: var(--card); }
.composer textarea { min-height: 48px; max-height: 160px; }
.composer .btn { min-height: 48px; }

.editor { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }
.editor details { margin-bottom: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.editor summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; font-weight: 650; cursor: pointer; list-style: none; }
.editor summary::-webkit-details-marker { display: none; }
.editor summary::after { content: ""; width: 9px; height: 9px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; flex: none; }
.editor details[open] > summary::after { transform: rotate(-135deg); }
.editor summary small { color: var(--muted); font-weight: 500; }
.editor .body { padding: 2px 16px 16px; display: grid; gap: 14px; }
.editor fieldset { margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 12px; }
.editor legend { padding: 0 6px; font-size: 14px; font-weight: 650; }
.list-items { display: grid; gap: 10px; }
.list-item { padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fcfbf9; display: grid; gap: 10px; }
.list-item .item-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 650; color: var(--muted); }
.iconbtn { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.iconbtn:hover { border-color: var(--ink); }
.iconbtn.danger:hover { border-color: var(--danger); color: var(--danger); }
.add { justify-self: start; }
.price-input { position: relative; }
.price-input::before { content: "€"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.price-input input { padding-left: 28px; }
.hours-row { display: grid; grid-template-columns: 92px 1fr; gap: 8px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.hours-row:first-child { border-top: 0; }
.hours-row .day { padding-top: 10px; font-weight: 600; font-size: 15px; }
.ranges { display: grid; gap: 6px; }
.range { display: flex; align-items: center; gap: 6px; }
.range input { min-width: 0; }
.closed { display: flex; align-items: center; gap: 8px; min-height: 44px; color: var(--muted); }
.closed input { width: 20px; min-height: 20px; }
.photo-field { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; }
.photo-field img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--soft); }
.savebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--card); }

.history { flex: 1; overflow-y: auto; margin: 0; padding: 8px 16px 20px; list-style: none; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.history .what { font-weight: 600; }
.history .when { color: var(--muted); font-size: 14px; }

.tabs .count { display: inline-block; min-width: 20px; margin-left: 4px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: 12px; line-height: 20px; text-align: center; }
.messages { flex: 1; overflow-y: auto; margin: 0; padding: 8px 16px 20px; list-style: none; }
.messages li { padding: 14px 0; border-top: 1px solid var(--line); }
.messages li:first-child { border-top: 0; }
.messages li.new .head strong::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: var(--brand); vertical-align: middle; }
.messages .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.messages .head a { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.messages .when { margin-left: auto; color: var(--muted); font-size: 14px; }
.messages .body { margin: 8px 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
.messages .empty { border: 0; padding: 24px 0; }

.preview { display: flex; flex-direction: column; min-height: 0; background: var(--soft); }
.preview-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.segmented { display: inline-flex; padding: 3px; border-radius: 10px; background: #e3dfd8; }
.segmented button { min-height: 34px; padding: 0 14px; border: 0; border-radius: 8px; background: none; font-size: 14px; font-weight: 650; color: var(--muted); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px #0000001a; }
.segmented button:disabled { opacity: .45; cursor: default; }
.frame-wrap { flex: 1; display: flex; justify-content: center; min-height: 0; padding: 0 16px 16px; }
.frame-wrap iframe { width: 100%; height: 100%; border: 0; border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.frame-wrap.phone iframe { width: 390px; max-width: 100%; border: 10px solid #16181d; border-radius: 34px; }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: #fff; font-weight: 600; box-shadow: 0 8px 24px #0003; }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .workspace { display: block; height: auto; }
  .draftbar:not([hidden]) + .workspace { height: auto; }
  .panel { border-right: 0; min-height: calc(100vh - 60px); }
  .only-mobile { display: block; }
  .preview { display: none; }
  .preview.show { display: flex; position: fixed; inset: 60px 0 0; z-index: 25; }
  .chat { min-height: 45vh; }
  .composer, .savebar { position: sticky; bottom: 0; }
  .frame-wrap.phone iframe { width: 100%; border: 0; border-radius: 0; }
  .frame-wrap { padding: 0; }
  .topbar { padding: 0 16px; }
  .topnav { gap: 14px; font-size: 14px; }
  .tabs { padding: 6px 8px 0; gap: 0; }
  .tabs button { flex: 1; padding: 10px 6px; font-size: 14px; }
}
