/* =========================================================================
   DayStayed - master stylesheet for the web admin area.
   Edit theme colors in :root; component sections follow.
   Loaded by lib/layout.php (dashboard, day log) and login.php.
   The setup wizard keeps its own inline styles (it runs before install).
   ========================================================================= */

:root {
  /* palette */
  --bg:       #f6f6f3;
  --surface:  #ffffff;
  --text:     #1a1816;
  --muted:    #6b6560;
  --brass:    #8a6d3b;
  --border:   #e8e5de;
  --soft:     #f0eee9;
  --green:    #1f7a4d;
  --red:      #b8423a;
  --amber:    #b5851f;

  /* form fields */
  --field-bg:        #f3efe6;
  --field-border:    #b8b1a4;
  --field-focus-ring: rgba(138,109,59,.18);

  /* shape + type */
  --radius:    12px;
  --radius-sm: 7px;
  --font: 'Open Sans', system-ui, -apple-system, Arial, sans-serif;
  --maxw: 1080px;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  margin: 0;
  line-height: 1.5;
}
a { color: var(--brass); }

h1 { font-size: 24px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 26px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- top bar / nav ---- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: 18px; padding: 12px 20px; }
.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; display: flex; align-items: center; }
.brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brass); margin-right: 8px; display: inline-block; }
.brand .brand-icon { width: 24px; height: 24px; border-radius: 6px; margin-right: 9px; display: inline-block; vertical-align: middle; }
.nav { display: flex; gap: 6px; margin-left: 8px; }
.nav a { padding: 6px 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600; }
.nav a.on { background: var(--soft); color: var(--text); }
.spacer { flex: 1; }
.who { font-size: 13px; color: var(--muted); }

/* ---- layout ---- */
.wrap { max-width: var(--maxw); margin: 28px auto; padding: 0 20px; }
.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 760px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }

/* ---- threshold meters + status pills ---- */
.big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter { height: 9px; background: var(--soft); border-radius: 6px; overflow: hidden; margin: 8px 0; }
.meter > span { display: block; height: 100%; background: var(--green); }
.meter.warn > span { background: var(--amber); }
.meter.critical > span { background: #cc6a1f; }
.meter.over > span { background: var(--red); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.pill.ok   { background: #e8f3ec; color: var(--green); }
.pill.warn { background: #f9f1dd; color: var(--amber); }
.pill.critical { background: #f8e3d0; color: #b5530f; }
.pill.over { background: #fbeaea; color: var(--red); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--soft); font-size: 12px; color: var(--muted); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--border); }
td { padding: 8px; border-bottom: 1px solid var(--border); }

/* ---- forms ---- */
label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 14px; }
input, select {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--field-bg);
}
input:focus, select:focus {
  outline: none; border-color: var(--brass); background: #fff;
  box-shadow: 0 0 0 3px var(--field-focus-ring);
}
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 160px; }

/* ---- buttons ---- */
.btn { display: inline-block; border: none; border-radius: 8px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--brass); color: #fff; }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--field-border); }
.btn-block { width: 100%; text-align: center; }
.btn-disabled { background: var(--soft); color: var(--muted); border: 1px solid var(--border); cursor: default; }
.btn-disabled:hover { background: var(--soft); }

/* ---- Pro gating (report sample) ---- */
.badge-pro { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--brass); color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .02em; vertical-align: middle; }
.upgrade-banner { background: var(--soft); border: 1px solid var(--border); border-left: 3px solid var(--brass); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 16px; font-size: 14px; }
.upgrade-banner strong { color: var(--brass); }
.sample-lock td { background: var(--soft); color: var(--muted); font-style: italic; text-align: center; padding: 12px; }

/* ---- flash / alerts ---- */
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.flash.ok  { background: #e8f3ec; border: 1px solid #a9d2ba; color: #1c5236; }
.flash.err { background: #fbeaea; border: 1px solid #e0b4b0; color: #7a2520; }

.disclaimer { font-size: 12px; color: var(--muted); margin-top: 24px; text-align: center; }

/* ---- page header with right-aligned actions ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.page-head h1 { margin: 0; }
.page-head .head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---- modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20,18,15,.45); display: none; align-items: flex-start; justify-content: center; z-index: 50; padding: 48px 16px; overflow: auto; }
.modal-backdrop.open { display: flex; }
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 460px; }
.modal-card h2 { margin: 0 0 4px; }
.modal-actions { margin-top: 18px; display: flex; gap: 10px; justify-content: flex-end; }

/* row action buttons */
.row-action { background: none; border: none; padding: 4px 6px; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--brass); text-decoration: none; display: inline-flex; align-items: center; vertical-align: middle; }
.row-action svg { display: block; }
.row-action.danger { color: var(--red); }
.row-action:hover { opacity: .7; }
.dup-flag { color: var(--amber); font-weight: 700; }

/* bulk action bar */
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--soft); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.bulk-bar[hidden] { display: none; }
.bulk-bar select { width: auto; min-width: 220px; }
.bulk-bar .bulk-count { font-weight: 600; font-size: 14px; margin-right: 4px; }

/* ---- database explorer ---- */
textarea { width: 100%; padding: 10px 12px; font-size: 13px; font-family: ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--field-border); border-radius: var(--radius-sm); background: var(--field-bg); }
textarea:focus { outline: none; border-color: var(--brass); background: #fff; box-shadow: 0 0 0 3px var(--field-focus-ring); }
.tablelist a { display: inline-block; margin: 0 8px 8px 0; padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px; background: var(--surface); text-decoration: none; color: var(--text); font-size: 13px; }
.tablelist a.on { background: var(--brass); color: #fff; border-color: var(--brass); }
.scroll { overflow-x: auto; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ---- audit report ---- */
.report-head { border-bottom: 2px solid var(--border); padding-bottom: 12px; margin-bottom: 8px; }

@media print {
  .topbar, .no-print, .disclaimer { display: none !important; }
  body { background: #fff; color: #000; }
  .wrap { margin: 0; padding: 0; max-width: none; }
  .report h1 { font-size: 18px; }
  .report h2 { font-size: 13px; margin: 14px 0 6px; }
  table { font-size: 10px; }
  th { border-bottom: 1px solid #000; }
  td { border-bottom: 1px solid #ccc; }
  a { color: #000; text-decoration: none; }
  thead { display: table-header-group; }   /* repeat headers across printed pages */
  tr { page-break-inside: avoid; }
}

/* ---- auth (login) ---- */
.auth-shell { max-width: 380px; margin: 14vh auto; padding: 0 20px; }
.auth-brand { font-weight: 700; font-size: 20px; margin-bottom: 18px; display: flex; align-items: center; }
.auth-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brass); margin-right: 9px; display: inline-block; }
.auth-brand .auth-logo { width: 40px; height: 40px; border-radius: 9px; margin-right: 11px; display: inline-block; }
.auth-error { background: #fbeaea; border: 1px solid #e0b4b0; color: #7a2520; padding: 10px 12px; border-radius: 8px; font-size: 14px; margin-bottom: 8px; }
.auth-shell .btn-primary { margin-top: 20px; padding: 12px; font-size: 15px; }
.auth-alt { margin-top: 14px; font-size: 13px; text-align: center; }
.auth-alt a { color: var(--brass); text-decoration: none; }
.auth-alt a:hover { text-decoration: underline; }
