/* Shared look of both portals (customer /app/ and master /admin/). Plain and quiet: tables, cards, one accent.
   Phone first: everything works at 360px wide. */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --ink: #1b2420;
  --ink-2: #566059;
  --line: #d8ddd6;
  --accent: #1f6f5f;
  --accent-dark: #16564a;
  --accent-tint: #e3f0ec;
  --warn: #9a6a12;
  --warn-tint: #fbf0d9;
  --bad: #a3343f;
  --bad-tint: #f8e7e8;
  --good: #2f7a3e;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #7fc7b5; outline-offset: 2px; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
a { color: var(--accent); }
h1 { font-size: 1.6rem; line-height: 1.15; font-weight: 700; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; line-height: 1.25; font-weight: 700; margin: 1.75rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: 0 0 1rem; }
.quiet { color: var(--ink-2); }
.small { font-size: .9rem; }
.mono { font-family: var(--mono); font-size: .9em; }
.lead { color: var(--ink-2); max-width: 36em; margin-bottom: 1.25rem; }

/* top bar with navigation */
.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.bar .brand { font-weight: 700; margin-right: 6px; white-space: nowrap; }
.bar .brand .sub { color: var(--ink-2); font-weight: 400; }
.bar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.bar nav a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.bar nav a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-dark); font-weight: 600; }
.bar .spacer { flex: 1; }
.notice { padding: 10px 16px; background: var(--warn-tint); color: var(--warn); border-bottom: 1px solid #ead9b0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.narrow { max-width: 440px; margin: 40px auto; }

/* cards and lists */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.card h3 { margin-top: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin: 8px 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin: 10px 0 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--ink-2); font-size: .9rem; }

/* status dots and badges */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #b8bfb9; vertical-align: middle; }
.dot.on { background: var(--good); }
.dot.off { background: var(--bad); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: #e8ebe7; color: var(--ink-2); }
.badge.good { background: var(--accent-tint); color: var(--accent-dark); }
.badge.warn { background: var(--warn-tint); color: var(--warn); }
.badge.bad { background: var(--bad-tint); color: var(--bad); }

/* tables (scroll sideways on phones) */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
th { color: var(--ink-2); font-weight: 600; font-size: .85rem; }
tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; }
tr.click { cursor: pointer; }
tr.click:hover { background: #fafbf9; }

/* forms */
.field { display: block; margin: 0 0 14px; }
.field > .label, .field > span.label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .help { display: block; color: var(--ink-2); font-size: .9rem; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; max-width: 460px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
textarea { min-height: 90px; font-family: var(--mono); font-size: .9rem; }
input.invalid { border-color: var(--bad); }
.pair { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; max-width: 700px; }
.pair label { font-size: .85rem; color: var(--ink-2); }
.pair input { max-width: none; }
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }
.btn { padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-weight: 600; min-height: 42px; }
.btn:hover { background: #f6f8f5; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 5px 10px; min-height: 32px; font-size: .9rem; }
.btn.link { border: 0; background: none; color: var(--accent); padding-left: 0; padding-right: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.error { color: var(--bad); font-weight: 600; }
details.more > summary { cursor: pointer; font-weight: 600; margin: 8px 0; }
pre { background: #f0f2ef; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; font-size: .82rem; max-height: 420px; white-space: pre-wrap; word-break: break-word; }

/* toasts and dialogs */
#toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px;
  max-width: calc(100vw - 32px); z-index: 50; display: flex; gap: 14px; align-items: center; }
#toast.bad { background: var(--bad); }
#toast button { background: none; border: 0; color: #9fe0cf; font-weight: 700; }
dialog { border: 0; border-radius: 14px; padding: 20px; width: min(640px, calc(100vw - 24px)); max-height: 90vh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,.4); }
.lang { font-size: .9rem; }
.lang button { background: none; border: 0; color: var(--ink-2); padding: 4px 6px; }
.lang button[aria-pressed=true] { color: var(--ink); font-weight: 700; }
@media (max-width: 600px) {
  .pair { grid-template-columns: 1fr; }
  main { padding: 14px 12px 60px; }
}
