/* ─── TechRecords – Main Stylesheet ─────────────────────────────────────────
   Colour palette derived from IT-Technology Enterprises logo (blues)
   ──────────────────────────────────────────────────────────────────────────── */

:root {
  --primary:       #4A90D9;
  --primary-dark:  #2C5282;
  --primary-light: #89C4E8;
  --primary-xlt:   #EBF5FB;
  --accent:        #2B6CB0;

  --bg:            #F7FAFD;
  --bg2:           #EBF5FB;
  --bg3:           #FFFFFF;
  --border:        #CBD5E0;
  --border2:       #BEE3F8;

  --text:          #2D3748;
  --text2:         #4A5568;
  --text3:         #718096;

  --success:       #38A169;
  --success-bg:    #F0FFF4;
  --success-border:#68D391;
  --warning:       #D69E2E;
  --warning-bg:    #FFFBEB;
  --warning-border:#F6AD55;
  --danger:        #E53E3E;
  --danger-bg:     #FFF5F5;
  --danger-border: #FC8181;
  --info:          #3182CE;
  --info-bg:       #EBF8FF;
  --info-border:   #90CDF4;

  --radius:        8px;
  --radius-lg:     12px;
  --shadow:        0 2px 8px rgba(44,82,130,.10);
  --shadow-lg:     0 4px 24px rgba(44,82,130,.15);
  --transition:    .18s ease;

  --header-h:      60px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
       background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh;
       display: flex; flex-direction: column; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.site-main { flex: 1; padding-top: calc(var(--header-h) + 16px); padding-bottom: 40px; }
.container  { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 16px; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.site-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--header-h); background: var(--bg3);
  border-bottom: 1.5px solid var(--border2); box-shadow: var(--shadow);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 0 16px;
  height: 100%; display: flex; align-items: center; gap: 16px;
}
.site-logo { display: flex; align-items: center; }
.logo-img { height: 36px; width: auto; display: block; }
.logo-icon { font-size: 1.3rem; }
.main-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.nav-link { padding: 6px 12px; border-radius: var(--radius); color: var(--text2); font-size: .9rem; font-weight: 500; transition: background var(--transition), color var(--transition); white-space: nowrap; }
.nav-link:hover, .nav-link.active { background: var(--primary-xlt); color: var(--primary-dark); }
.nav-toggle { display: none; background: none; border: none; font-size: 1.4rem; color: var(--text2); padding: 4px 8px; }
.nav-user { display: flex; align-items: center; gap: 8px; margin-left: 12px; padding-left: 12px; border-left: 1.5px solid var(--border); }
.nav-username { font-size: .88rem; font-weight: 600; color: var(--text); }
.nav-role { font-size: .75rem; padding: 2px 8px; border-radius: 20px; font-weight: 600; text-transform: capitalize; }
.role-admin       { background: #EBF8FF; color: #2B6CB0; }
.role-accounts    { background: #E9D8FD; color: #553C9A; }
.role-technician  { background: var(--primary-xlt); color: var(--primary-dark); }
.nav-logout { color: var(--danger); }
.nav-logout:hover { background: var(--danger-bg); color: var(--danger); }

/* ── Footer ──────────────────────────────────────────────────────────────── */
.site-footer { background: var(--bg3); border-top: 1.5px solid var(--border); padding: 12px 16px; }
.footer-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; font-size: .82rem; color: var(--text3); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { background: var(--bg3); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px; margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1.5px solid var(--border); }
.card-title { font-size: 1.1rem; font-weight: 700; color: var(--primary-dark); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       padding: 9px 18px; border-radius: var(--radius); border: 1.5px solid transparent;
       font-size: .9rem; font-weight: 600; transition: all var(--transition); white-space: nowrap; }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color:#fff; }
.btn-secondary { background: var(--bg3); color: var(--text2); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg2); border-color: var(--primary-light); color: var(--text); }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #276749; color:#fff; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #c53030; color:#fff; }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm { padding: 5px 12px; font-size: .82rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); border: 1.5px solid; margin-bottom: 16px; font-size: .92rem; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: #276749; }
.alert-danger  { background: var(--danger-bg);  border-color: var(--danger-border);  color: #c53030; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-border); color: #744210; }
.alert-info    { background: var(--info-bg);    border-color: var(--info-border);    color: #2b6cb0; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
label { display: block; font-size: .85rem; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
label .req { color: var(--danger); margin-left: 2px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], input[type=tel], input[type=url], textarea, select {
  width: 100%; padding: 9px 13px; border: 1.5px solid var(--border); border-radius: var(--radius);
  font-size: .95rem; font-family: inherit; color: var(--text); background: var(--bg3);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(74,144,217,.15);
}
textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: .8rem; color: var(--text3); margin-top: 4px; }
.form-error { font-size: .8rem; color: var(--danger); margin-top: 4px; }
.input-err { border-color: var(--danger) !important; }

/* Checkboxes & radios */
.check-group { display: flex; align-items: center; gap: 10px; }
.check-group input[type=checkbox], .check-group input[type=radio] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.check-group label { margin: 0; font-weight: 500; cursor: pointer; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th { background: var(--bg2); padding: 10px 14px; text-align: left; font-size: .8rem;
                 font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text2);
                 border-bottom: 2px solid var(--border2); white-space: nowrap; }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tbody tr:hover { background: var(--primary-xlt); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.badge-draft     { background: #EDF2F7; color: #4A5568; }
.badge-submitted { background: #EBF8FF; color: #2B6CB0; }
.badge-closed    { background: #F0FFF4; color: #276749; }
.badge-low    { background: #F7FAFC; color: #718096; }
.badge-normal { background: var(--primary-xlt); color: var(--primary-dark); }
.badge-high   { background: #FFFBEB; color: #744210; }
.badge-urgent { background: var(--danger-bg); color: var(--danger); }
.badge-sla    { background: #E9D8FD; color: #553C9A; }
.badge-adhoc  { background: #EDF2F7; color: #4A5568; }

/* ── Badges resolved ─────────────────────────────────────────────────────── */
.badge-yes { background: var(--success-bg); color: var(--success); }
.badge-no  { background: var(--danger-bg);  color: var(--danger); }

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-title  { font-size: 1.5rem; font-weight: 700; color: var(--primary-dark); }
.page-subtitle { font-size: .9rem; color: var(--text3); margin-top: 2px; }

/* ── Alpha filter ────────────────────────────────────────────────────────── */
.alpha-filter { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px;
                margin: 0 0 1rem; padding: .5rem; background: var(--bg2);
                border: 1.5px solid var(--border); border-radius: var(--radius); }
.alpha-btn { min-width: 30px; height: 30px; padding: 0 8px; border: 1.5px solid var(--border);
             background: var(--bg3); color: var(--text); border-radius: var(--radius);
             font-size: .82rem; font-weight: 600; transition: all var(--transition); }
.alpha-btn:hover  { background: var(--primary-xlt); border-color: var(--primary); color: var(--primary-dark); }
.alpha-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Dashboard split ─────────────────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.dash-panel { background: var(--bg3); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.dash-panel-header { padding: 14px 20px; border-bottom: 1.5px solid var(--border2); display: flex; justify-content: space-between; align-items: center; }
.dash-panel-title { font-weight: 700; font-size: 1rem; color: var(--primary-dark); }
.dash-panel-count { font-size: .82rem; color: var(--text3); }
.dash-panel-body { padding: 0; }
.dash-job-item { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.dash-job-item:last-child { border-bottom: none; }
.dash-job-item:hover { background: var(--primary-xlt); }
.dash-job-num  { font-size: .78rem; font-weight: 700; color: var(--text3); }
.dash-job-title { font-weight: 600; font-size: .92rem; color: var(--text); }
.dash-job-meta  { font-size: .78rem; color: var(--text3); margin-top: 2px; }
.dash-empty { padding: 32px 20px; text-align: center; color: var(--text3); font-size: .9rem; }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--bg3); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 18px 20px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label { font-size: .82rem; color: var(--text3); margin-top: 4px; }

.dash-calendar-section { margin-top: 24px; }
.cal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.cal-card { background: var(--bg3); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.cal-card-header { padding: 14px 20px; border-bottom: 1.5px solid var(--border2); font-weight: 700; font-size: .95rem; color: var(--primary-dark); text-align: center; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); padding: 10px 10px 0; }
.cal-weekdays span { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text3); text-align: center; }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; padding: 8px 10px 16px; }
.cal-day { position: relative; aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; border-radius: var(--radius); font-size: .8rem; color: var(--text2); }
.cal-day-empty { visibility: hidden; }
.cal-day-past { color: var(--text3); opacity: .55; }
.cal-day-has-jobs { background: var(--primary-xlt); color: var(--primary-dark); font-weight: 600; }
.cal-day-today { background: var(--primary); color: #fff; font-weight: 700; }
.cal-day-today.cal-day-has-jobs { background: var(--primary); color: #fff; }
.cal-day-dot { position: absolute; bottom: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--danger); }
.cal-day-today .cal-day-dot { background: #fff; }

/* Vertical sidebar variant (e.g. job card create page) */
.cal-grid-vertical { display: flex; flex-direction: column; grid-template-columns: none; }
.cal-grid-vertical .cal-day { font-size: .75rem; }

.jc-layout { display: flex; align-items: flex-start; gap: 24px; max-width: 1040px; margin: 0 auto; padding: 0 16px; }
.jc-form-col { flex: 1 1 720px; max-width: 720px; min-width: 0; }
.jc-sidebar { width: 280px; flex-shrink: 0; position: sticky; top: calc(var(--header-h) + 16px); }

/* ── Job card form ───────────────────────────────────────────────────────── */
.section-title { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary); margin: 24px 0 14px; border-bottom: 1.5px solid var(--border2); padding-bottom: 6px; }

/* Line items table */
.line-items-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: .9rem; }
.line-items-table th { background: var(--bg2); padding: 8px 10px; text-align: left; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); border-bottom: 1.5px solid var(--border2); }
.line-items-table td { padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.line-items-table input { padding: 6px 8px; font-size: .88rem; }
.line-items-table .col-qty   { width: 80px; }
.line-items-table .col-price { width: 110px; }
.line-items-table .col-del   { width: 40px; text-align: center; }
.btn-row-del { background: none; border: none; color: var(--text3); font-size: 1.1rem; padding: 4px 6px; border-radius: 4px; }
.btn-row-del:hover { color: var(--danger); background: var(--danger-bg); }

/* Time rows table */
.time-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: .9rem; }
.time-table th { background: var(--bg2); padding: 8px 10px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); border-bottom: 1.5px solid var(--border2); text-align: left; }
.time-table td { padding: 6px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.time-table input { padding: 6px 8px; font-size: .88rem; }
.col-date  { width: 150px; }
.col-time  { width: 120px; }
.time-total { font-weight: 700; color: var(--primary-dark); font-size: .95rem; }

/* Photo grid */
.photo-grid { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.photo-thumb { position: relative; width: 100px; height: 100px; border-radius: var(--radius); overflow: hidden; border: 2px solid var(--border); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.photo-del { position: absolute; top: 3px; right: 3px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 50%; width: 20px; height: 20px; font-size: .75rem; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.photo-add { width: 100px; height: 100px; border: 2px dashed var(--border); border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; color: var(--text3); font-size: .75rem; transition: all var(--transition); }
.photo-add:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-xlt); }

/* Signature */
.sig-wrap { border: 1.5px solid var(--border); border-radius: var(--radius); background: #fff; position: relative; }
.sig-wrap canvas { display: block; width: 100%; touch-action: none; cursor: crosshair; }
.sig-toolbar { display: flex; justify-content: flex-end; padding: 8px; border-top: 1px solid var(--border); gap: 8px; }
.sig-hint { font-size: .78rem; color: var(--text3); padding: 6px 10px; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 9999; display: flex; align-items: center; justify-content: center; }
.lightbox.hidden { display: none; }
.lightbox img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }
.lb-close { position: absolute; top: 16px; right: 20px; background: none; border: none; color: #fff; font-size: 2rem; cursor: pointer; }

/* Combobox */
.combo-wrap { position: relative; }
.combo-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg3); border: 1.5px solid var(--primary); border-top: none; border-radius: 0 0 var(--radius) var(--radius); max-height: 200px; overflow-y: auto; z-index: 100; box-shadow: var(--shadow-lg); }
.combo-option { padding: 9px 13px; cursor: pointer; font-size: .9rem; }
.combo-option:hover, .combo-option.active { background: var(--primary-xlt); color: var(--primary-dark); }
.combo-empty { padding: 9px 13px; color: var(--text3); font-size: .88rem; }

/* ── Autocomplete ────────────────────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg3); border: 1.5px solid var(--primary); border-top: none; border-radius: 0 0 var(--radius) var(--radius); max-height: 180px; overflow-y: auto; z-index: 100; box-shadow: var(--shadow-lg); display: none; }
.autocomplete-list.open { display: block; }
.autocomplete-item { padding: 8px 13px; cursor: pointer; font-size: .88rem; display: flex; justify-content: space-between; align-items: center; }
.autocomplete-item:hover { background: var(--primary-xlt); }
.autocomplete-price { color: var(--text3); font-size: .8rem; }

/* ── View job card ───────────────────────────────────────────────────────── */
.jc-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 20px; margin-bottom: 20px; }
.jc-meta-item label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 2px; }
.jc-meta-item .value { font-size: .95rem; font-weight: 600; color: var(--text); }
.history-item { padding: 10px 14px; border-left: 3px solid var(--primary-light); margin-bottom: 8px; background: var(--bg2); border-radius: 0 var(--radius) var(--radius) 0; font-size: .88rem; }
.history-date { font-size: .78rem; color: var(--text3); }

/* ── Filters bar ─────────────────────────────────────────────────────────── */
.filter-bar { background: var(--bg3); border: 1.5px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 20px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* ── Lock banner ─────────────────────────────────────────────────────────── */
.lock-banner { background: var(--warning-bg); border: 1.5px solid var(--warning-border); color: #744210; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: .9rem; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; }
.page-btn { min-width: 36px; height: 36px; padding: 0 10px; border: 1.5px solid var(--border); background: var(--bg3); color: var(--text2); border-radius: var(--radius); font-size: .88rem; font-weight: 600; transition: all var(--transition); }
.page-btn:hover { background: var(--primary-xlt); border-color: var(--primary); color: var(--primary-dark); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-card { background: var(--bg3); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px; width: 100%; max-width: 420px; }
.login-logo     { text-align: center; margin-bottom: 28px; }
.login-logo-img { max-width: 220px; height: auto; margin: 0 auto 10px; display: block; }
.login-logo .logo-sub { font-size: .9rem; color: var(--text3); }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text3); font-size: .88rem; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.fw-bold { font-weight: 700; }
.divider { border: none; border-top: 1.5px solid var(--border); margin: 24px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text3); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 10px; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .cal-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .jc-layout { flex-direction: column; }
  .jc-form-col { max-width: 720px; margin: 0 auto; width: 100%; }
  .jc-sidebar { width: 100%; max-width: 720px; margin: 0 auto; position: static; }
  .jc-sidebar .cal-grid-vertical { flex-direction: row; flex-wrap: wrap; }
  .jc-sidebar .cal-grid-vertical .cal-card { flex: 1 1 220px; }
}
@media (max-width: 768px) {
  .main-nav { display: none; position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
              background: var(--bg3); flex-direction: column; padding: 20px 16px; gap: 4px;
              overflow-y: auto; box-shadow: var(--shadow-lg); z-index: 999; }
  .main-nav.open { display: flex; }
  .nav-toggle { display: block; margin-left: auto; }
  .nav-user { flex-direction: column; align-items: flex-start; border-left: none; padding-left: 0; margin-left: 0; border-top: 1.5px solid var(--border); padding-top: 12px; margin-top: 8px; width: 100%; }
  .nav-link { padding: 10px 12px; width: 100%; }
  .dash-grid { grid-template-columns: 1fr; }
  .cal-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .card { padding: 16px; }
}
@media (max-width: 480px) {
  .dash-stats { grid-template-columns: 1fr 1fr; }
  .photo-thumb, .photo-add { width: 80px; height: 80px; }
  .login-card { padding: 24px 16px; }
}

/* ══ Renewals module ═════════════════════════════════════════════════════════ */
.badge-cancelled { background: #EDF2F7; color: #718096; }

/* Service type badges */
.svc-type         { font-weight: 600; }
.svc-type-domain  { background: #EBF8FF; color: #2B6CB0; }
.svc-type-hosting { background: #E9D8FD; color: #553C9A; }
.svc-type-ssl     { background: #F0FFF4; color: #276749; }
.svc-type-other   { background: #EDF2F7; color: #4A5568; }

/* Due badges + row bands */
.due-badge      { font-weight: 700; white-space: nowrap; }
.due-overdue    { background: var(--danger-bg);  color: #C53030; }
.due-due30      { background: var(--warning-bg); color: #975A16; }
.due-due60      { background: var(--info-bg);    color: #2B6CB0; }
.due-later      { background: #F7FAFC;           color: var(--text3); }
.due-cancelled  { background: #EDF2F7;           color: #718096; }
.svc-row.band-overdue td:first-child, .dash-job-item.band-overdue { box-shadow: inset 4px 0 0 var(--danger); }
.svc-row.band-due30   td:first-child, .dash-job-item.band-due30   { box-shadow: inset 4px 0 0 var(--warning); }
.svc-row.band-due60   td:first-child, .dash-job-item.band-due60   { box-shadow: inset 4px 0 0 var(--info); }
.svc-row.band-overdue { background: #FFFAFA; }
.svc-row.band-cancelled { opacity: .6; }
.svc-row.is-selected, .svc-row.is-selected:hover { background: #E6F2FF; }
.svc-row.other-client.is-selected { background: #FFF8E6; }

/* Services table */
.svc-table .svc-check { width: 38px; text-align: center; }
.svc-table .svc-check input { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.svc-name   { font-weight: 700; color: var(--primary-dark); overflow-wrap: anywhere; }
.svc-client { font-weight: 600; color: var(--text); }
.svc-sub    { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 3px; font-size: .8rem; }
.svc-sub .badge { font-size: .7rem; padding: 2px 8px; }
.svc-due    { font-weight: 600; white-space: nowrap; }
.svc-price  { font-weight: 600; white-space: nowrap; }
.svc-notified { white-space: nowrap; font-size: .85rem; }
.svc-actions { text-align: right; }
.svc-actions .btn-group { justify-content: flex-end; flex-wrap: nowrap; }

/* Clickable stat cards */
.stat-link { display: block; color: inherit; transition: box-shadow var(--transition), transform var(--transition); }
.stat-link:hover { color: inherit; box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.stat-active { outline: 2px solid var(--primary); }

/* Selection action bar (sticks to bottom of screen) */
.svc-actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 900; background: var(--bg3);
                 border-top: 2px solid var(--primary); box-shadow: 0 -4px 20px rgba(44,82,130,.18); padding: 10px 16px; }
.svc-actionbar-inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.svc-actionbar-warn  { max-width: 1200px; margin: 8px auto 0; font-size: .85rem; color: #744210; background: var(--warning-bg);
                       border: 1.5px solid var(--warning-border); border-radius: var(--radius); padding: 8px 12px; }
body.has-actionbar .site-footer { padding-bottom: 110px; }

/* Type picker (create/edit) */
.svc-type-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.svc-type-opt { margin: 0; cursor: pointer; }
.svc-type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.svc-type-opt span { display: block; text-align: center; padding: 10px 6px; border: 1.5px solid var(--border); border-radius: var(--radius);
                     font-weight: 600; color: var(--text2); background: var(--bg3); transition: all var(--transition); }
.svc-type-opt input:checked + span { border-color: var(--primary); background: var(--primary-xlt); color: var(--primary-dark); box-shadow: 0 0 0 3px rgba(74,144,217,.15); }
.svc-type-opt input:focus-visible + span { outline: 2px solid var(--primary); }

/* Modals */
.modal { position: fixed; inset: 0; z-index: 2000; background: rgba(26,32,44,.55); display: flex; align-items: flex-start; justify-content: center;
         padding: 40px 16px; overflow-y: auto; }
.modal.hidden { display: none; }
.modal-box { background: var(--bg3); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; display: flex; flex-direction: column; }
.modal-lg  { max-width: 760px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1.5px solid var(--border2); }
.modal-head h2 { font-size: 1.15rem; color: var(--primary-dark); }
.modal-x { background: none; border: none; font-size: 1.6rem; line-height: 1; color: var(--text3); padding: 0 4px; }
.modal-x:hover { color: var(--danger); }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 14px 20px; border-top: 1.5px solid var(--border); background: var(--bg); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.modal-lead { margin-bottom: 14px; }
body.modal-open { overflow: hidden; }

/* Notify popup */
.n-recipients { display: flex; flex-direction: column; gap: 6px; }
.n-rcpt { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: var(--radius);
          font-weight: 400; cursor: pointer; overflow-wrap: anywhere; }
.n-rcpt input { width: 18px; height: 18px; margin-top: 2px; flex-shrink: 0; accent-color: var(--primary); }
.n-rcpt:has(input:checked) { border-color: var(--primary-light); background: var(--primary-xlt); }
.n-rcpt-bad { opacity: .6; cursor: not-allowed; }
.n-items { border: 1.5px dashed var(--border2); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 16px; font-size: .88rem; }
.n-items-head { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 6px; }
.n-item { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.n-item:last-child { border-bottom: none; }
.n-preview, .email-frame { width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius); background: #F7FAFD; }
.n-preview   { height: 460px; }
.email-frame { height: 75vh; min-height: 300px; border: none; border-radius: 0; display: block; }

/* Email record */
.email-meta { display: flex; flex-direction: column; gap: 10px; font-size: .9rem; }
.email-meta label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin-bottom: 1px; }
.email-meta > div > div { overflow-wrap: anywhere; }

/* Config page */
.cfg-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.cfg-tab  { padding: 7px 14px; border-radius: 20px; background: var(--bg3); border: 1.5px solid var(--border); color: var(--text2); font-size: .88rem; font-weight: 600; }
.cfg-tab:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-xlt); }
.cfg-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.cfg-test { display: flex; gap: 8px; flex: 1 1 320px; max-width: 480px; }
.cfg-test input { flex: 1; min-width: 0; }
.cfg-debug { margin-top: 10px; }
.cfg-debug summary { cursor: pointer; font-size: .85rem; color: var(--text2); font-weight: 600; }
.cfg-debug pre { margin-top: 8px; max-height: 320px; overflow: auto; background: #1A202C; color: #E2E8F0; padding: 12px; border-radius: var(--radius); font-size: .75rem; white-space: pre-wrap; word-break: break-all; }
.cfg-placeholders { background: var(--bg2); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: .85rem; }
.cfg-placeholders code, .form-hint code, .alert code { background: var(--bg3); border: 1px solid var(--border2); border-radius: 4px; padding: 0 4px; font-size: .8rem; }
.card[id] { scroll-margin-top: calc(var(--header-h) + 16px); }

/* Dashboard widget */
.dash-renewals { margin-top: 20px; }

@media (max-width: 768px) {
  /* Services table → stacked cards */
  .svc-table thead { display: none; }
  .svc-table, .svc-table tbody, .svc-table tr, .svc-table td { display: block; width: 100%; }
  .svc-table tr.svc-row { position: relative; padding: 12px 14px 12px 48px; border-bottom: 1px solid var(--border); }
  .svc-table td { border: none; padding: 2px 0; }
  .svc-table td[data-label]::before { content: attr(data-label) ": "; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text3); font-weight: 700; }
  .svc-table td[data-label="Service"]::before, .svc-table td[data-label="Client"]::before { content: none; }
  .svc-table td.svc-check { position: absolute; left: 10px; top: 14px; width: auto; }
  .svc-table td.svc-check input { width: 22px; height: 22px; }
  .svc-table td.text-right { text-align: left; }
  .svc-table .svc-actions { margin-top: 8px; text-align: left; }
  .svc-table .svc-actions .btn-group { justify-content: flex-start; }
  .svc-table .svc-actions .btn { padding: 8px 14px; }
  .svc-table .svc-due { display: inline; margin-right: 6px; }
  .svc-row.band-overdue td:first-child, .svc-row.band-due30 td:first-child, .svc-row.band-due60 td:first-child { box-shadow: none; }
  .svc-row.band-overdue { box-shadow: inset 4px 0 0 var(--danger); }
  .svc-row.band-due30   { box-shadow: inset 4px 0 0 var(--warning); }
  .svc-row.band-due60   { box-shadow: inset 4px 0 0 var(--info); }
  .svc-table:not(:has(.svc-check)) tr.svc-row { padding-left: 14px; }
  .svc-actionbar .btn-group { width: 100%; }
  .svc-actionbar .btn-group .btn { flex: 1; padding: 10px 8px; }
  .svc-type-picker { grid-template-columns: repeat(2, 1fr); }
  .modal { padding: 0; align-items: stretch; }
  .modal-box, .modal-lg { max-width: none; min-height: 100%; border-radius: 0; }
  .modal-body { flex: 1; }
  .modal-foot { border-radius: 0; position: sticky; bottom: 0; }
  .modal-foot .btn { flex: 1; }
  .n-preview { height: 380px; }
  .cfg-test { max-width: none; }
}

/* ── Attachments (renewal notices) ─────────────────────────────────────────── */
.n-drop { display: block; margin: 0; padding: 14px; text-align: center; border: 2px dashed var(--border); border-radius: var(--radius);
          color: var(--text2); font-weight: 400; cursor: pointer; transition: all var(--transition); }
.n-drop:hover, .n-drop.is-over { border-color: var(--primary); background: var(--primary-xlt); color: var(--primary-dark); }
.n-files { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.n-file  { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 10px; background: var(--bg2);
           border-radius: var(--radius); font-size: .88rem; overflow-wrap: anywhere; }
.att-list { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; font-size: .82rem; }
.att-link { color: var(--primary-dark); font-weight: 600; overflow-wrap: anywhere; }
.att-missing { color: var(--text3); font-weight: 400; }
.data-table tr.att-row td { padding-top: 0; border-top: none; }

/* ── Config: transport picker + help ───────────────────────────────────────── */
.cfg-transport { grid-template-columns: repeat(2, minmax(0, 260px)); margin-bottom: 8px; }
.cfg-help { margin: 4px 0 8px; background: var(--bg2); border-radius: var(--radius); padding: 10px 14px; font-size: .88rem; }
.cfg-help summary { cursor: pointer; font-weight: 600; color: var(--primary-dark); }
.cfg-help ol { margin: 10px 0 4px 18px; display: flex; flex-direction: column; gap: 8px; }
.cfg-help pre { margin: 6px 0; background: #1A202C; color: #E2E8F0; padding: 10px; border-radius: var(--radius); font-size: .75rem; white-space: pre-wrap; word-break: break-all; }
@media (max-width: 768px) { .cfg-transport { grid-template-columns: 1fr 1fr; } }

/* ── Dashboard: upcoming renewals as tiles ────────────────────────────────── */
.rw-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 14px; }
.rw-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius);
           background: var(--bg3); color: inherit; min-width: 0; transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition); }
.rw-tile:hover { color: inherit; border-color: var(--primary-light); box-shadow: var(--shadow); transform: translateY(-1px); }
.rw-tile.band-overdue { border-left: 4px solid var(--danger); background: #FFFAFA; }
.rw-tile.band-due30   { border-left: 4px solid var(--warning); }
.rw-tile.band-due60   { border-left: 4px solid var(--info); }
.rw-tile.dash-job-item, .rw-tile { box-shadow: none; }
.rw-top  { display: flex; justify-content: space-between; align-items: center; gap: 6px; flex-wrap: wrap; }
.rw-top .badge { font-size: .7rem; padding: 2px 8px; }
.rw-name { font-weight: 700; font-size: .92rem; color: var(--primary-dark); overflow-wrap: anywhere; line-height: 1.3; margin-top: 4px; }
.rw-client { font-size: .8rem; color: var(--text2); }
.rw-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: auto; padding-top: 6px;
           border-top: 1px solid var(--border); font-size: .78rem; color: var(--text3); }
.rw-foot strong { color: var(--text); font-size: .85rem; white-space: nowrap; }
@media (max-width: 1024px) { .rw-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px)  { .rw-grid { grid-template-columns: 1fr; padding: 10px; } }

/* ── Service page: cancel ──────────────────────────────────────────────────── */
.btn-cancel-svc { background: var(--bg3); color: var(--danger); border-color: var(--danger-border); }
.btn-cancel-svc:hover { background: var(--danger-bg); color: #C53030; border-color: var(--danger); }
.cancel-panel { border: 1.5px solid var(--danger-border); }
