/* iPreminder portal — built phone-first, then widened for desktop. */
:root {
  --bg: #f6f5f2; --card: #fff; --ink: #1c1c1a; --muted: #6b6a66;
  --line: #e3e1dc; --accent: #1f6f5c; --warn: #9a3b1f;
  --tap: 44px;                 /* smallest comfortable size for a fingertip */
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 -apple-system, system-ui, "Segoe UI", sans-serif;
       background: var(--bg); color: var(--ink); }
a { color: var(--accent); }

/* ---------- header ---------- */
header { display: flex; gap: 12px; align-items: center; padding: 10px 16px;
         background: var(--card); border-bottom: 1px solid var(--line);
         position: sticky; top: 0; z-index: 10; }
header .brand { font-weight: 700; color: var(--ink); text-decoration: none; }
header .who { color: var(--muted); flex: 1; min-width: 0;
              overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header form { margin: 0; }
header button.link { min-height: var(--tap); }

main { max-width: 1000px; margin: 0 auto; padding: 16px; }
h1 { margin: 0 0 4px; font-size: 22px; line-height: 1.25; }
h2 { font-size: 17px; margin: 24px 0 8px; }
.card h2 { margin-top: 0; }
.muted { color: var(--muted); margin-top: 0; }
.small { font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.narrow { max-width: 400px; margin: 32px auto; }
.narrow-form { max-width: 520px; }
.title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }

/* ---------- forms ---------- */
label { display: block; margin: 12px 0; font-weight: 500; }
/* 16px text stops iPhones zooming in every time a box is tapped. */
input, textarea, select { display: block; width: 100%; margin-top: 6px; padding: 12px;
        font: inherit; font-size: 16px; color: var(--ink); background: #fff;
        border: 1px solid #cfccc5; border-radius: 8px; min-height: var(--tap); }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type=date] { -webkit-appearance: none; appearance: none; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 4px 14px 10px; margin: 16px 0; }
legend { font-weight: 600; padding: 0 6px; }
label.check { display: flex; gap: 12px; align-items: center; font-weight: 400; min-height: var(--tap); margin: 4px 0; }
label.check input { width: 22px; height: 22px; min-height: 0; margin: 0; flex: none; accent-color: var(--accent); }

button { min-height: var(--tap); padding: 10px 18px; font: inherit; font-weight: 600; border: 0; border-radius: 8px;
         background: var(--accent); color: #fff; cursor: pointer; touch-action: manipulation; }
button.wide { width: 100%; margin-top: 8px; }
button.link { background: none; color: var(--accent); padding: 8px 4px; font-weight: 500; }
button.danger, .danger-text { color: var(--warn); }
.button { display: inline-flex; align-items: center; min-height: var(--tap); padding: 10px 16px; border-radius: 8px;
          background: var(--accent); color: #fff; text-decoration: none; white-space: nowrap; font-weight: 600; }
.button.secondary { background: var(--card); color: var(--accent); border: 1px solid var(--line); }

.flash { background: #fbeee9; color: var(--warn); padding: 12px; border-radius: 8px; margin-top: 0; }
.flash.ok { background: #e8f3ef; color: var(--accent); }
.tag { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 99px;
       background: var(--line); color: var(--muted); vertical-align: middle; }

/* ---------- main switch ---------- */
.main-switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
               background: var(--card); border: 1px solid var(--line); border-radius: 12px;
               padding: 12px 16px; margin: 0 0 16px; }
.main-switch.off { background: #fbeee9; border-color: #f0c9bb; color: var(--warn); }
.main-switch button.toggle { background: var(--line); color: var(--ink); }
.main-switch.off button.toggle { background: var(--accent); color: #fff; }

/* ---------- customer list (cards, so nothing gets cut off on a phone) ---------- */
.customer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.customer-card { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
                 padding: 14px 16px; color: var(--ink); text-decoration: none; }
.customer-card:active { background: #f0efea; }
.cc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.cc-name { font-weight: 600; font-size: 17px; color: var(--accent); min-width: 0; overflow-wrap: anywhere; }
.cc-balance { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cc-balance.owing { color: var(--warn); }
.cc-meta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
           color: var(--muted); font-size: 14px; margin-top: 4px; }
.cc-extra { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; color: var(--muted);
            font-size: 14px; margin-top: 6px; }
.cc-comment { font-style: italic; }
.customer-card.paid .cc-balance { color: var(--muted); }
.customer-card.inactive { opacity: .7; }

/* ---------- customer page ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.stat span { display: block; font-size: 13px; color: var(--muted); }
.stat strong { display: block; font-size: 17px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat strong.owing { color: var(--warn); }
.comments { white-space: pre-wrap; }
.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
.two-col > section > h2:first-child { margin-top: 0; }

.history { list-style: none; margin: 0; padding: 0; background: var(--card);
           border: 1px solid var(--line); border-radius: 12px; }
.history li { display: flex; justify-content: space-between; align-items: center; gap: 12px;
              padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.history li:last-child { border-bottom: 0; }
.history li > div { min-width: 0; }
.history strong { font-variant-numeric: tabular-nums; margin-right: 8px; }
.history form { margin: 0; flex: none; }
.history.texts li { padding: 12px 16px; }

.switches { margin-top: 24px; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px;
              padding: 6px 0; border-bottom: 1px solid var(--line); margin: 0; }
.switches > form:last-child { margin-top: 8px; }
button.toggle { min-width: 72px; background: var(--line); color: var(--muted); }
button.toggle.on { background: var(--accent); color: #fff; }

/* ---------- wider screens ---------- */
@media (min-width: 720px) {
  main { padding: 24px; }
  .two-col { grid-template-columns: 1fr 1fr; }
  button.wide { width: auto; }
  .stat strong { font-size: 20px; }
  .customer-list { grid-template-columns: 1fr 1fr; }
}
