/* Gig Requests — plain, fast, readable. No external fonts or frameworks. */

:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --border: #deddd6;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --danger: #c0352b;
  --warn-bg: #fff4e0;
  --warn-border: #f0b44c;
  --private-bg: #fbf7e9;
  --private-border: #e3d49a;
  --client-bg: #f1f5fd;
  --client-border: #c8d6f4;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);

  --st-new: #2f5bd3;
  --st-needs-reply: #c0352b;
  --st-waiting: #5f6b7a;
  --st-follow-up: #b86e00;
  --st-tentative: #7a4cc2;
  --st-confirmed: #1d7f45;
  --st-declined: #8a8a85;
  --st-cancelled: #8a8a85;
  --st-completed: #276f6f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #212120;
    --text: #ecebe6;
    --muted: #a3a29b;
    --border: #3a3a37;
    --accent: #6f93ff;
    --accent-text: #0f1220;
    --danger: #ff7366;
    --warn-bg: #3a2c12;
    --warn-border: #a8771e;
    --private-bg: #2d2a1c;
    --private-border: #5d5530;
    --client-bg: #1d2436;
    --client-border: #34436b;
    --st-new: #6f93ff;
    --st-needs-reply: #ff7366;
    --st-waiting: #9aa6b5;
    --st-follow-up: #f0a63a;
    --st-tentative: #b28cf0;
    --st-confirmed: #4fc27f;
    --st-declined: #8d8d87;
    --st-cancelled: #8d8d87;
    --st-completed: #55baba;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; margin-top: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
code { font-size: .9em; background: var(--bg); padding: .1em .3em; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.num { text-align: right; }
.empty { color: var(--muted); font-style: italic; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---- Header / navigation ---- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: .5rem 1rem;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; text-decoration: none; color: var(--text); white-space: nowrap; }
.main-nav { display: flex; align-items: center; gap: .25rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.main-nav a, .main-nav .link-button {
  padding: .45rem .7rem; border-radius: 6px; text-decoration: none; color: var(--text); white-space: nowrap;
}
.main-nav a:hover, .main-nav .link-button:hover { background: var(--bg); }
.main-nav a.active { background: var(--bg); font-weight: 600; }
.main-nav a.nav-new { color: var(--accent); font-weight: 600; }
.nav-logout { margin: 0 0 0 auto; }
.link-button { background: none; border: 0; font: inherit; cursor: pointer; color: var(--muted); }

.container { max-width: 1200px; margin: 0 auto; padding: 1rem; }
.narrow { max-width: 620px; margin-left: auto; margin-right: auto; }

/* ---- Cards, layout ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-bottom: 1rem;
}
.page-head, .section-head {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.page-head h1, .section-head h2 { margin: 0; }
.actions, .button-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.button-row form { margin: 0; }
.breadcrumb { margin: 0 0 .75rem; }
.breadcrumb a { text-decoration: none; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.detail-grid > .card { margin-bottom: 0; }
.detail-grid { margin-bottom: 1rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; align-items: start; }
.dashboard-grid > .card { margin-bottom: 0; }

/* ---- Buttons ---- */
.button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.5rem; padding: .45rem .95rem;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.button:hover { border-color: var(--muted); }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.primary:hover { filter: brightness(1.08); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.danger-outline { color: var(--danger); border-color: var(--danger); }
.button.block { width: 100%; }
.danger-link { color: var(--danger); }
.push-right { margin-left: auto; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---- Flash messages ---- */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash-success { background: #e6f4ea; border-color: #9fd1ae; color: #14532d; }
.flash-error { background: #fdecea; border-color: #f0a8a1; color: #7f1d1d; }
.flash-info { background: var(--client-bg); border-color: var(--client-border); color: var(--text); }
@media (prefers-color-scheme: dark) {
  .flash-success { background: #133022; border-color: #2c6a45; color: #b7f0cb; }
  .flash-error { background: #3a1714; border-color: #8a3a32; color: #ffc9c2; }
}

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .78rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  border: 1px solid currentColor; vertical-align: middle;
}
.badge-new { color: var(--st-new); }
.badge-needs-reply { color: #fff; background: var(--st-needs-reply); border-color: var(--st-needs-reply); }
.badge-waiting { color: var(--st-waiting); }
.badge-follow-up { color: var(--st-follow-up); }
.badge-tentative { color: var(--st-tentative); }
.badge-confirmed { color: #fff; background: var(--st-confirmed); border-color: var(--st-confirmed); }
.badge-declined { color: var(--st-declined); }
.badge-cancelled { color: var(--st-cancelled); text-decoration: line-through; }
.badge-completed { color: var(--st-completed); }
.badge-unknown { color: var(--muted); }
.badge-priority-high { color: var(--danger); border-style: dashed; }
.badge-priority-low { color: var(--muted); border-style: dashed; }
.badge-overdue { color: #fff; background: var(--danger); border-color: var(--danger); }
.badge-today { color: var(--st-follow-up); }
.overdue { color: var(--danger); font-weight: 600; }
.due-today { color: var(--st-follow-up); font-weight: 600; }

/* ---- Dashboard ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--muted);
  border-radius: var(--radius); padding: .75rem 1rem; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column;
}
.tile:hover { border-color: var(--muted); }
.tile-count { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.tile-label { color: var(--muted); font-size: .9rem; }
.tile-new { border-left-color: var(--st-new); }
.tile-needs-reply { border-left-color: var(--st-needs-reply); }
.tile-follow-up { border-left-color: var(--st-follow-up); }
.tile-overdue { border-left-color: var(--danger); background: var(--warn-bg); }
.tile-waiting { border-left-color: var(--st-waiting); }
.tile-tentative { border-left-color: var(--st-tentative); }
.tile-confirmed { border-left-color: var(--st-confirmed); }

.quick-search, .search-row { display: flex; gap: .5rem; margin-bottom: 1rem; }
.quick-search input, .search-row input { flex: 1; min-width: 0; }

.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li { border-top: 1px solid var(--border); }
.item-list li:first-child { border-top: 0; }
.item-list a { display: block; padding: .6rem .25rem; text-decoration: none; color: var(--text); }
.item-list a:hover { background: var(--bg); }
.item-top, .item-title, .item-meta, .item-note { display: block; }
.item-title { margin-top: .15rem; }
.item-meta { font-size: .85rem; }
.item-note { font-size: .85rem; background: var(--private-bg); border-left: 3px solid var(--private-border); padding: .1rem .5rem; margin-top: .25rem; }
.trash-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; flex-wrap: wrap; }

/* ---- Request table ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.request-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.request-table th, .request-table td { padding: .55rem .65rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.request-table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: var(--bg); }
.request-table th.num, .request-table td.num { text-align: right; }
.request-table tbody tr { cursor: pointer; }
.request-table tbody tr:hover { background: var(--bg); }
.request-table tbody tr:last-child td { border-bottom: 0; }
.request-table .cell-main a { font-weight: 600; text-decoration: none; color: var(--text); }
.row-overdue td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.row-due-today td:first-child { box-shadow: inset 4px 0 0 var(--st-follow-up); }

.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1rem 0; }

/* ---- Forms ---- */
.form fieldset.card { min-width: 0; }
fieldset { border: 1px solid var(--border); }
legend { font-weight: 700; padding: 0 .35rem; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; min-width: 0; }
.field label, .radio-group legend { font-weight: 600; font-size: .9rem; }
input[type=text], input[type=email], input[type=tel], input[type=url], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], input[type=password], input[type=search], select, textarea {
  width: 100%; min-height: 2.5rem; padding: .45rem .6rem;
  font: inherit; font-size: 16px; /* 16px prevents iOS zoom on focus */
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid transparent; box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: .85rem; }
.hint { color: var(--muted); font-size: .88rem; margin: -.25rem 0 .75rem; }
.radio-group { border: 0; padding: 0; margin: 0 0 .8rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.radio-group legend { padding: 0; margin-bottom: .25rem; width: 100%; }
.radio { display: inline-flex; align-items: center; gap: .4rem; min-height: 2.25rem; cursor: pointer; }
.radio input { width: 1.15rem; height: 1.15rem; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }
.sticky-actions {
  position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0;
  border-top: 1px solid var(--border); z-index: 5;
}
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 1rem; }

/* Client info vs private info must never look the same. */
.client-zone { background: var(--client-bg); border-color: var(--client-border); }
.private-zone { background: var(--private-bg); border-color: var(--private-border); }
.private-zone > .field label::before, .private-zone legend::before, .private-zone h2::before { content: "🔒 "; }

.filter-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem 1rem; margin-bottom: 1rem; }
.filter-panel summary { cursor: pointer; font-weight: 600; padding: .25rem 0; }
.filter-panel[open] summary { margin-bottom: .75rem; }

/* ---- Request detail ---- */
.request-header { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.request-header h1 { margin-bottom: .3rem; }
.request-sub { margin: 0 0 .3rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.request-header .muted { margin: 0; }
.request-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-start; }

.quick-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 1rem; margin-bottom: 1rem; }
.quick-actions .card { margin-bottom: 0; }
.quick-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.quick-form .field { margin-bottom: 0; flex: 1 1 160px; }
.quick-form.is-overdue, .card.is-overdue { border-color: var(--danger); background: var(--warn-bg); }

.dl { margin: 0; }
.dl-row { display: grid; grid-template-columns: 8rem 1fr; gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--border); }
.dl-row:first-child { border-top: 0; }
.dl dt { color: var(--muted); font-size: .9rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }

/* ---- Timeline ---- */
.timeline { list-style: none; margin: 0 0 1rem; padding: 0; }
.timeline-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .7rem .9rem; margin-bottom: .75rem; background: var(--surface);
  max-width: 92%;
}
.timeline-item.incoming { border-left: 4px solid var(--st-new); margin-right: auto; }
.timeline-item.outgoing { border-left: 4px solid var(--st-confirmed); margin-left: auto; background: color-mix(in srgb, var(--st-confirmed) 6%, var(--surface)); }
.timeline-item.original { background: var(--client-bg); }
.timeline-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: baseline; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.timeline-tools { margin-left: auto; display: flex; gap: .75rem; }
.dir { font-weight: 700; }
.dir-incoming { color: var(--st-new); }
.dir-outgoing { color: var(--st-confirmed); }
.subject { font-weight: 600; margin-bottom: .2rem; }
.message { overflow-wrap: anywhere; }
.message.clamp { max-height: 12rem; overflow: auto; }
.private-note { margin-top: .5rem; padding: .4rem .6rem; background: var(--private-bg); border: 1px dashed var(--private-border); border-radius: 6px; font-size: .9rem; }
.private-label { display: block; font-size: .75rem; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.private-label::before { content: "🔒 "; }

.add-comm > summary { list-style: none; width: max-content; }
.add-comm > summary::-webkit-details-marker { display: none; }
.add-comm[open] > summary { display: none; }
.comm-form { border-top: 1px solid var(--border); padding-top: 1rem; }
.private-zone .field { margin-bottom: 0; }
.comm-form .private-zone { padding: .6rem .75rem; border: 1px solid var(--private-border); border-radius: 6px; margin-bottom: .8rem; }

/* ---- Misc pages ---- */
.login-box { max-width: 380px; margin: 8vh auto 0; }
.login-box h1 { text-align: center; }
.confirm-card h1 { color: var(--danger); }
.error-card { margin-top: 10vh; }
.error-detail { white-space: pre-wrap; font-size: .85rem; background: var(--bg); padding: .5rem; border-radius: 6px; }
.plain-list { padding-left: 1.2rem; }
.plain-list li { margin-bottom: .4rem; }

/* ---- Mobile ---- */
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .quick-actions { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .container { padding: .75rem; }
  .site-header { padding: .4rem .5rem; gap: .5rem; }
  .brand { display: none; }
  .main-nav { flex-wrap: wrap; overflow: visible; gap: .1rem; }
  .main-nav a, .main-nav .link-button { padding: .4rem .5rem; font-size: .95rem; }
  .detail-grid, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .timeline-item { max-width: 100%; }
  .request-actions .button, .page-head .button { flex: 1 1 auto; }
  .dl-row { grid-template-columns: 6.5rem 1fr; }

  /* Table becomes a stack of cards. */
  .table-wrap { background: none; border: 0; overflow: visible; }
  .request-table, .request-table tbody, .request-table tr, .request-table td { display: block; width: 100%; }
  .request-table thead { display: none; }
  .request-table tr {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: .6rem; padding: .4rem .6rem;
  }
  .request-table td { border: 0; padding: .15rem 0; display: flex; gap: .5rem; text-align: left; }
  .request-table td.num { text-align: left; }
  .request-table td::before { content: attr(data-label); flex: 0 0 6.5rem; color: var(--muted); font-size: .8rem; padding-top: .1rem; }
  .request-table td:empty { display: none; }
  .request-table td.cell-main { font-size: 1.05rem; }
  .row-overdue { border-left: 4px solid var(--danger) !important; }
  .row-due-today { border-left: 4px solid var(--st-follow-up) !important; }
  .row-overdue td:first-child, .row-due-today td:first-child { box-shadow: none; }
}

@media print {
  .site-header, .request-actions, .quick-actions, .add-comm, .timeline-tools, .section-head .button { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; }
}
