:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #1f6f4a;
  --accent-soft: #e8f3ed;
  --danger: #b4232b;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 "Segoe UI", -apple-system, system-ui, sans-serif;
}
button { font: inherit; cursor: pointer; border-radius: 6px; border: 1px solid var(--line);
         background: #fff; padding: 6px 12px; }
button:hover { border-color: #c4c9d0; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1a5c3d; }
button.ghost { background: #fff; }
button.danger { color: var(--danger); border-color: #e7c3c5; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.mini { padding: 1px 8px; font-size: 13px; line-height: 1.4; }
input, select { font: inherit; padding: 6px 8px; border: 1px solid var(--line);
                border-radius: 6px; background: #fff; color: inherit; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
/* Read-only fields still take focus (so they stay keyboard-reachable and
   selectable) but must not look like something you can type into. */
input[readonly] { background: #f4f4f6; color: var(--muted); cursor: default; }
input[readonly]:focus { outline: none; border-color: var(--line); }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; letter-spacing: .2px; }
.brand span { color: var(--accent); margin-left: 4px; font-weight: 600; }
.tabs { display: flex; gap: 4px; }
.tab { border: none; background: transparent; padding: 6px 14px; border-radius: 20px; color: var(--muted); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.stats { margin-left: auto; color: var(--muted); font-size: 13px; }

/* ---------- filters ---------- */
.view { padding: 14px 18px 40px; }
.filters, .actionbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px; margin-bottom: 10px;
}
.filters #q { flex: 2 1 280px; }
.filters select { flex: 1 1 150px; max-width: 220px; }
.chk { display: flex; align-items: center; gap: 5px; white-space: nowrap; color: var(--muted); }
.chk input { width: auto; }

/* ---------- table ---------- */
.tablewrap { background: var(--panel); border: 1px solid var(--line);
             border-radius: var(--radius); overflow: auto; }
.tablewrap.short { max-height: 340px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line);
         vertical-align: top; }
th { position: sticky; top: 0; background: #fafbfc; font-weight: 600; z-index: 1;
     white-space: nowrap; border-bottom: 1px solid var(--line); }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--accent); }
th.num, td.num { text-align: right; }
th.cb, td.cb { width: 30px; }
td.cb input { width: auto; }
tbody tr:hover { background: #f9fbfa; }
tbody tr.clickable { cursor: pointer; }
.name { font-weight: 600; }
.addr { color: var(--muted); max-width: 320px; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px;
        background: var(--accent-soft); color: var(--accent); }

/* ---------- who am I / admin ---------- */
.whoami { display: flex; align-items: center; gap: 6px; margin-left: 12px; }
.whoami .mini { padding: 2px 9px; }
.rights { display: grid; grid-template-columns: 1fr; gap: 4px; margin: 6px 0 12px; }
.rights .chk { color: var(--ink); white-space: normal; }
.hint { font-size: 12px; margin: 0 0 6px; }
#tbl-users td, #tbl-history td { vertical-align: top; }
.tagrow { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px;
       background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag.off { background: #f0f0f2; color: var(--muted); }
.diff { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: 12px; line-height: 1.5; }
.diff .was { color: #a12626; }
.diff .now { color: #17692f; }
.when { white-space: nowrap; font-size: 12px; }

/* ---------- multi-select filter ---------- */
.ms { position: relative; }
.ms-btn { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-btn.on { border-color: var(--accent); color: var(--accent); }
.ms-panel { position: absolute; z-index: 40; top: calc(100% + 4px); left: 0;
            width: 320px; max-width: 80vw; padding: 8px;
            background: var(--card, #fff); border: 1px solid var(--line, #d7d7dc);
            border-radius: 8px; box-shadow: 0 8px 28px rgba(0,0,0,.14); }
.ms-panel[hidden] { display: none; }
.ms-panel-right { left: auto; right: 0; width: 240px; }
.ms-search { width: 100%; margin-bottom: 6px; }
.ms-list { max-height: 280px; overflow-y: auto; overflow-x: hidden; }
.ms-opt { display: flex; gap: 8px; align-items: flex-start;
          padding: 5px 6px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.ms-opt:hover { background: var(--accent-soft); }
.ms-opt input[type="checkbox"] { width: auto; flex: none;
                                 margin: 2px 0 0; padding: 0; }
.ms-opt span { flex: 1 1 auto; min-width: 0; color: var(--ink); line-height: 1.35; }
.ms-mode { display: flex; gap: 7px; align-items: center; margin: 6px 2px 0;
            font-size: 12px; }
.ms-mode input:disabled + *, .ms-mode:has(input:disabled) { opacity: .45; }
.ms-foot { display: flex; gap: 6px; align-items: center; padding-top: 8px; margin-top: 4px;
           border-top: 1px solid var(--line, #e5e5ea); }

.sr { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
       font-size: 12px; letter-spacing: .5px; white-space: nowrap;
       color: var(--muted); width: 1%; }

td.evcell { white-space: normal; min-width: 150px; }
td.evcell .pill { margin: 1px 3px 1px 0; }

.pager { display: flex; gap: 10px; align-items: center; padding: 10px 2px; }
.pager select { width: auto; }

/* ---------- guest lists ---------- */
.lists-layout { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
.occasions { background: var(--panel); border: 1px solid var(--line);
             border-radius: var(--radius); padding: 8px; max-height: 78vh; overflow: auto; }
.occ { margin-bottom: 10px; }
.occ h4 { margin: 6px 6px 4px; font-size: 13px; }
.occ .sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.evt { display: flex; align-items: center; gap: 8px; padding: 5px 8px;
       border-radius: 6px; cursor: pointer; font-size: 13px; }
.evt:hover { background: #f2f5f3; }
.evt.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.evt .cnt { margin-left: auto; font-size: 11px; color: var(--muted); }
.listhead { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.listhead h2 { margin: 0; font-size: 17px; }

/* ---------- lookups ---------- */
.lookup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 12px; }
.card h3 { margin: 0 0 10px; font-size: 14px; display: flex; align-items: center; gap: 8px; }

/* ---------- dialogs ---------- */
dialog { border: none; border-radius: 10px; padding: 0; width: min(860px, 94vw);
         box-shadow: 0 18px 50px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(15,20,25,.45); }
dialog form { padding: 18px 20px 14px; }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.grid3 .span2 { grid-column: span 2; }
.grid3 .span3 { grid-column: span 3; }
label { display: block; font-size: 12px; color: var(--muted); }
label input, label select { margin-top: 3px; color: var(--ink); }
.dlgfoot { display: flex; gap: 8px; align-items: center; margin-top: 16px;
           border-top: 1px solid var(--line); padding-top: 12px; }
.invbox { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.invbox h3 { margin: 0 0 8px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 26px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px;
        background: var(--accent-soft); color: var(--accent); border-radius: 14px; font-size: 12px; }
.chip button { border: none; background: transparent; color: inherit; padding: 0 4px;
               font-size: 14px; line-height: 1; }
.invadd { display: flex; gap: 8px; margin-top: 10px; }
.invadd select { flex: 1; }

/* A checkbox list standing in for <select multiple>, which iOS renders as a
   popover that clips every option to "PRANAV MARRIAGE…". */
.picklist { border: 1px solid var(--line); border-radius: 6px; padding: 4px;
            margin-top: 4px; max-height: 44vh; }
#bulk-search { margin-top: 4px; }

/* A word in a sentence that happens to be clickable. */
.linkish { border: none; background: none; padding: 0; font: inherit; cursor: pointer;
           color: var(--accent); text-decoration: underline; }
.linkish:hover { opacity: .8; }

/* ---------- import ---------- */
#dlg-import { width: min(760px, 94vw); }
.imp-help { margin: 4px 0 12px; font-size: 12px; color: var(--muted); }
.imp-help summary { cursor: pointer; }
.imp-help ul { margin: 8px 0; padding-left: 18px; }
.imp-help li { margin-bottom: 4px; }
.imp-help code { background: #f0f0f2; padding: 0 4px; border-radius: 3px; }
.impfile { display: block; margin: 10px 0; }
/* The global input rule stretches a file picker across the dialog. */
.impfile input[type="file"] { width: auto; margin-top: 4px; }
.impcols { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
            margin: 12px 0 4px; padding: 10px 12px; border: 1px solid var(--line);
            border-radius: 6px; background: var(--panel); font-size: 13px; }
.impcols .chk { margin: 0; }
.impcols .muted { flex-basis: 100%; font-size: 12px; }
.impsum { margin: 10px 0 2px; }
.impbad { color: #b42318; margin: 10px 0; }
#tbl-import td { vertical-align: top; }
.tag.add  { background: #e7f6ec; color: #17663a; }
.tag.drop { background: #fdecec; color: #b42318; }
.tag.bad  { background: #fdecec; color: #b42318; }
.tag.note { background: #fff6e5; color: #8a5a00; }
#tbl-import .tag { white-space: normal; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
         background: #16181d; color: #fff; padding: 9px 16px; border-radius: 20px;
         font-size: 13px; z-index: 99; }

@media (max-width: 900px) {
  .lists-layout { grid-template-columns: 1fr; }
  .grid3 { grid-template-columns: repeat(2, 1fr); }
  .grid3 .span3 { grid-column: span 2; }
}
