:root {
  --bg: #f4f3ee;
  --surface: #ffffff;
  --text: #1a170f;
  --muted: #6b6557;
  --border: #e3e0d6;
  --primary: #c15f3c;
  --green: #2f8f5b;
  --green-bg: #e6f4ec;
  --red: #c0392b;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must always win — otherwise display:grid/flex on a
   view (e.g. .login-wrap) overrides the UA stylesheet's display:none. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

h1, h2 { margin: 0; font-weight: 600; }

button { font: inherit; cursor: pointer; border-radius: 8px; transition: filter .15s ease, background .15s ease; }
button:active { transform: scale(0.98); }

input, select {
  font: inherit;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(193, 95, 60, .35); outline-offset: 0; border-color: var(--primary); }

/* ─── Login ─── */
.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  display: flex;
  flex-direction: column;
}
.login-card h1 { font-size: 22px; }
.login-card .sub { color: var(--muted); margin: 4px 0 20px; }
.login-card label { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.login-card input { margin-bottom: 16px; }
.login-card button {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 11px;
  font-weight: 600;
  margin-top: 4px;
}
.login-card button:hover { filter: brightness(1.07); }
.error { color: var(--red); font-size: 13px; margin: 12px 0 0; }

/* ─── Topbar ─── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--text);
  color: #f4f3ee;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar .brand { font-weight: 700; letter-spacing: .2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: #cfc9bb; font-size: 13px; }
.ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,.25);
  color: #f4f3ee;
  padding: 6px 12px;
}
.ghost:hover { background: rgba(255,255,255,.1); }

/* ─── Layout ─── */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }
.container.narrow { max-width: 560px; }

/* ─── Panel ─── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 24px;
  overflow: hidden;
}
.panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 { font-size: 16px; }
.primary { background: var(--primary); color: #fff; border: none; padding: 11px 14px; font-weight: 600; }
.primary:hover { filter: brightness(1.07); }
.primary:disabled { opacity: .6; cursor: not-allowed; }

/* ─── Generator form ─── */
.gen-body { padding: 18px; display: flex; flex-direction: column; }
.gen-body label { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.opt { font-weight: 400; opacity: .8; }

/* invoice ref row + copy icon */
.ref-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: rgba(255, 255, 255, .7);
  border: 1px solid #bfe0cc;
  border-radius: 7px;
  color: var(--muted);
}
.icon-btn:hover { background: #fff; color: var(--text); }
.icon-btn.copied { color: var(--green); border-color: var(--green); }
.gen-body input, .gen-body select { margin-bottom: 16px; }
.gen-body .primary { margin-top: 4px; }

/* ─── Generated link box ─── */
.key-box {
  margin: 0 18px 18px;
  padding: 14px 16px;
  background: var(--green-bg);
  border: 1px solid #bfe0cc;
  border-radius: 10px;
  font-size: 13px;
}
.key-box .k {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 600;
  word-break: break-all;
  margin-top: 8px;
  padding: 10px;
  background: rgba(255,255,255,.7);
  border-radius: 8px;
}
.key-box .note { color: var(--muted); margin-top: 10px; }
.gen-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btn-light {
  display: inline-block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
}
.btn-light:hover { background: rgba(0,0,0,.03); }
