/* CyRaSri Console: the look of cyrasri.com — paper and ink, "Ra" in copper, Fraunces for names and headings,
   IBM Plex Sans for the rest. Light or dark, as the device says or as chosen. */
:root {
  --paper: #F6F2EA; --paper-2: #EFE9DD; --card: #FBF8F2; --ink: #1C1B19; --ink-2: #4A463F; --muted: #6B655B; --line: #DDD5C6;
  --accent: #8A4B22; --accent-ink: #FFFFFF; --accent-soft: #F1E2D3; --ok: #2F6B4F; --ok-soft: #DDEBDF; --warn: #9A3B26; --warn-soft: #F5DED6;
  --wait: #7A5A12; --wait-soft: #F3E7C8;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif; --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'IBM Plex Mono', ui-monospace, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16150F; --paper-2: #1E1C16; --card: #22201A; --ink: #F1ECE2; --ink-2: #C9C1B2; --muted: #A39B8C; --line: #37332A;
    --accent: #D9935F; --accent-ink: #16150F; --accent-soft: #3A2A1D; --ok: #7FC39E; --ok-soft: #1F3328; --warn: #F0A08A; --warn-soft: #3E231C; --wait: #E3C47A; --wait-soft: #3A3120;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #16150F; --paper-2: #1E1C16; --card: #22201A; --ink: #F1ECE2; --ink-2: #C9C1B2; --muted: #A39B8C; --line: #37332A;
  --accent: #D9935F; --accent-ink: #16150F; --accent-soft: #3A2A1D; --ok: #7FC39E; --ok-soft: #1F3328; --warn: #F0A08A; --warn-soft: #3E231C; --wait: #E3C47A; --wait-soft: #3A3120;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: clamp(26px, 2.2vw, 36px); line-height: 1.15; }
h2 { font-size: 19px; }
h3.sub { font-size: 15px; font-family: var(--sans); font-weight: 600; margin: 18px 0 8px; }
p { margin: 0 0 10px; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); } .small { font-size: 13px; } .warn-text { color: var(--warn); }
.pre { white-space: pre-wrap; } .nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 8px; z-index: 99; }
.skip:focus { left: 8px; }
.eyebrow .pchip { text-transform: none; letter-spacing: 0; }
.eyebrow { font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); font-weight: 500; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }

/* The name */
.wm { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.wm .ra { color: var(--accent); }
.wm-big { font-size: 46px; line-height: 1; }
.tag { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 2px; font-weight: 500; }

/* Bar and side menu */
.bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 24px; min-height: 68px;
  background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand .wm { font-size: 28px; line-height: 1; }
.bar-tools { display: flex; align-items: center; gap: 8px; }
.inline { display: inline; margin: 0; }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; font-size: 18px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { border-color: var(--ink); }
.menu-btn { display: none; }
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: calc(100vh - 68px - 56px); }
.side { position: sticky; top: 68px; align-self: start; display: flex; flex-direction: column; gap: 2px; padding: 22px 14px; height: calc(100vh - 68px); border-right: 1px solid var(--line); }
.side a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; }
.side a:hover { background: var(--paper-2); color: var(--ink); }
.side a.on { background: var(--ink); color: var(--paper); }
.side a .dot { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.side-who { margin-top: auto; font-size: 13px; color: var(--muted); padding: 0 12px; }
.main { padding: 28px clamp(16px, 3vw, 40px) 48px; max-width: 1480px; width: 100%; }
.foot { border-top: 1px solid var(--line); padding: 16px 24px; font-size: 13px; color: var(--muted); text-align: center; }
.foot .wm { font-size: 14px; }

/* Page head */
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; margin-bottom: 22px; }
.page-head p.muted { margin: 6px 0 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 20px; border-radius: 999px; font: 600 14px/1 var(--sans); text-decoration: none; cursor: pointer; border: 1.5px solid transparent; transition: background .15s, color .15s, border-color .15s; }
.btn.sm { min-height: 34px; padding: 0 14px; font-size: 13px; }
.btn.solid { background: var(--ink); color: var(--paper); }
.btn.solid:hover { background: var(--accent); color: var(--accent-ink); }
.btn.line { border-color: var(--ink); color: var(--ink); background: transparent; }
.btn.line:hover { background: var(--ink); color: var(--paper); }
.btn.ghost { color: var(--ink-2); background: transparent; }
.btn.ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn.danger { color: var(--warn); }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* Boxes */
.box { background: var(--card); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 18px; overflow: hidden; }
.box-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.box-extra { font-size: 13px; }
.box-body { padding: 16px 20px; }
.box-body > :last-child { margin-bottom: 0; }
.note-box { border-color: var(--accent); }
.empty { color: var(--muted); margin: 4px 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; align-items: start; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0 18px; align-items: start; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-decoration: none; color: var(--ink); }
.tile:hover { border-color: var(--accent); }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-family: var(--serif); font-size: 34px; line-height: 1.1; }
.tile-sub { font-size: 12.5px; color: var(--muted); }

/* Rows */
.rows { list-style: none; margin: -6px -20px; padding: 0; }
.rows li + li { border-top: 1px solid var(--line); }
.rows a, .row-static { display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: var(--ink); text-decoration: none; }
.rows a:hover { background: var(--paper-2); }
.row-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-main b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main b.unseen { font-weight: 700; }
.row-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-when { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.new { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.dir { color: var(--muted); width: 14px; flex: none; }
.plain { list-style: none; padding: 0; margin: 0; }

/* Product chips: each product in its own colour */
.pchip { --pc: var(--accent); display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--pc) 55%, transparent); background: color-mix(in srgb, var(--pc) 13%, transparent); color: var(--ink); }
.pchip::before { content: ""; width: 8px; height: 8px; border-radius: 3px; background: var(--pc); }
h1 .pchip { font-size: 22px; padding: 6px 16px 6px 13px; font-family: var(--serif); font-weight: 500; }
h1 .pchip::before { width: 12px; height: 12px; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--paper-2); color: var(--ink-2); text-transform: none; }
.b-open, .q-declined { background: var(--warn-soft); color: var(--warn); }
.b-wait, .q-sent, .st-quoted { background: var(--wait-soft); color: var(--wait); }
.b-closed, .st-former, .q-draft { background: var(--paper-2); color: var(--muted); }
.st-client, .q-accepted { background: var(--ok-soft); color: var(--ok); }
.st-prospect { background: var(--accent-soft); color: var(--accent); }
.q-sent::first-letter, .q-draft::first-letter, .q-accepted::first-letter, .q-declined::first-letter { text-transform: uppercase; }

/* Tabs and toolbars */
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs a { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); text-decoration: none; font-size: 13.5px; font-weight: 500; }
.tabs a.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.tabs .count { opacity: .65; margin-left: 2px; }
.search input { min-width: 240px; }

/* Tables */
.table-wrap { overflow-x: auto; margin: -16px -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--paper-2); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 20px; } .table th:last-child, .table td:last-child { padding-right: 20px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr[data-href] { cursor: pointer; }
.table tr[data-href]:hover td { background: var(--paper-2); }
.table.lines textarea { min-width: 260px; }
.short { width: 70px; text-align: right; } .mid { width: 120px; text-align: right; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 24px; max-width: 380px; margin: 26px 0 0 auto; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--muted); } .totals dd { margin: 0; text-align: right; }
.totals .strong { color: var(--ink); font-weight: 700; padding-bottom: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0 0 14px; }
.facts dt { color: var(--muted); font-size: 13px; } .facts dd { margin: 0; }

/* Forms */
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.grid-form .span2, .grid-form .form-end { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label small { font-weight: 400; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
input, select, textarea { font: 400 15px/1.4 var(--sans); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type=color] { padding: 3px; height: 42px; }
input[type=file] { padding: 8px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin: 0; }
.table .inline-form { flex-wrap: nowrap; }
.inline-form select { width: auto; max-width: 220px; padding: 6px 10px; }
.inline-form label { flex-direction: row; align-items: center; gap: 8px; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.split { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.keyline { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.keyline code { background: var(--paper-2); padding: 8px 12px; border-radius: 8px; word-break: break-all; }
.steps { padding-left: 20px; margin: 8px 0 14px; } .steps li { margin-bottom: 6px; }
.howto summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-bottom: 8px; }

/* Flash */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--card); }
.flash.ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.flash.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }

/* Conversations */
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.thread li { max-width: 86%; padding: 12px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper); }
.thread li.mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.thread li.note { align-self: center; max-width: 100%; background: transparent; border: 0; padding: 0; text-align: center; font-size: 13px; color: var(--muted); }
.thread li.note p { margin: 0; }
.msg-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; margin-bottom: 4px; }
.msg-head small { color: var(--muted); }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.files { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; }
.mail-frame { width: 100%; height: 62vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }

/* Login */
body.login { display: flex; flex-direction: column; min-height: 100vh; }
.login-card { width: min(440px, calc(100% - 32px)); margin: auto; padding: 36px 34px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-card h1 { font-size: 26px; margin-bottom: 14px; }
.qr { background: #fff; padding: 12px; border-radius: 12px; width: 220px; margin: 0 auto 10px; }
.qr svg { width: 100%; height: auto; display: block; }

/* Smaller screens */
@media (max-width: 1200px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-side { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .side { position: fixed; top: 68px; left: 0; bottom: 0; height: auto; width: 260px; z-index: 40; background: var(--paper); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 0 20px 40px rgba(0,0,0,.18); }
  body.menu-open .side { transform: none; }
  .bar { padding: 0 16px; }
  .brand .wm { font-size: 24px; }
  .bar-tools .btn { display: none; }
}
@media (max-width: 560px) {
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .grid-form { grid-template-columns: minmax(0, 1fr); }
  .thread li { max-width: 100%; }
  .search input { min-width: 0; }
  .tag { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
