/* ============================================================
   Workwise Galgom Solutions - app.css
   ERPNext-inspired design system (external stylesheet, no inline styles)
   Replaces Bootstrap entirely. Scale = 110%.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
    --bg-page: #fbfbfc;
    --bg-surface: #ffffff;
    --bg-subtle: #f6f8f9;
    --bg-hover: #f2f5f7;
    --bg-active: #e8f0fb;
    --brand: #2490ef;
    --brand-hover: #1d7bcd;
    --brand-text: #ffffff;
    --blue-bg: #ecf5fe;

    --text: #1f272e;
    --text-muted: #687178;
    --text-light: #a1a9b0;
    --border: #e4e8eb;
    --border-strong: #d0d7dd;

    --radius: 9px;
    --radius-sm: 5px;

    --green: #2e7d32;   --green-bg: #e6f4e6;
    --red: #c0392b;     --red-bg: #fdecea;
    --amber: #b45309;   --amber-bg: #fef3e0;
    --gray: #687178;    --gray-bg: #f0f2f5;

    --sidebar-w: 253px;
    --topbar-h: 62px;

    --shadow-sm: 0 1px 2px rgba(31, 39, 46, .08);
    --shadow: 0 1px 3px rgba(31, 39, 46, .1), 0 1px 4px rgba(31, 39, 46, .08);

    --font: 'Inter', 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ---------- Reset / base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16.5px; }   /* 15px x 1.10 -> 110% scale */

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg-page);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); text-decoration: underline; }

code {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 7px;
    font-size: .88em;
}

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform .2s ease;
}

/* Brand: name wraps on two lines so it stays fully readable */
.sidebar-brand {
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: .1px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    white-space: normal;
    overflow: visible;
}
.sidebar-brand .brand-dot {
    display: inline-block;
    width: 25px; height: 25px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--brand), #5aa7f0);
    margin-right: 11px;
    flex: none;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 13px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--text-light);
    padding: 13px 11px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: .93rem;
    transition: background .12s ease, color .12s ease;
}
.nav-link:hover {
    background: var(--bg-hover);
    color: var(--text);
    text-decoration: none;
}
.nav-link.active {
    background: var(--bg-active);
    color: var(--brand);
}
.nav-icon {
    width: 20px; height: 20px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.nav-icon svg {
    width: 100%; height: 100%;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 13px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.sidebar-footer .user-chip {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 7px 9px;
}
.sidebar-footer .user-chip .avatar {
    width: 35px; height: 35px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--brand-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .85rem;
    flex: none;
}
.sidebar-footer .user-chip .user-meta { min-width: 0; }
.sidebar-footer .user-chip .user-name {
    font-weight: 600;
    font-size: .88rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-footer .user-chip .user-role {
    font-size: .75rem;
    color: var(--text-muted);
}

/* ---------- Main column ---------- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-h);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.brand-inline { display: none; }

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 7px;
    border-radius: var(--radius-sm);
    line-height: 1;
    color: var(--text-muted);
}
.sidebar-toggle svg {
    width: 24px; height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
}
.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text); }

.topbar-crumb {
    font-size: .93rem;
    color: var(--text-muted);
}
.topbar-crumb .crumb-sep { margin: 0 8px; color: var(--border-strong); }

/* ---------- Content ---------- */
.content {
    flex: 1;
    padding: 28px 31px 44px;
    width: 100%;
    max-width: 1400px;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -.2px;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: .9rem;
    margin-bottom: 21px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font);
    font-size: .9rem;
    font-weight: 500;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    line-height: 1.4;
    background: transparent;
}
/* Space between adjacent buttons */
.btn + .btn { margin-left: 11px; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--brand); color: var(--brand-text); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-hover); color: var(--brand-text); text-decoration: none; }

.btn-outline {
    border-color: var(--border-strong);
    color: var(--text);
    background: var(--bg-surface);
}
.btn-outline:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }

.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }

.btn-danger-outline {
    border-color: var(--red);
    color: var(--red);
    background: var(--bg-surface);
}
.btn-danger-outline:hover { background: var(--red-bg); color: var(--red); text-decoration: none; }

.btn-block { display: flex; width: 100%; justify-content: center; padding: 11px 16px; font-size: .95rem; font-weight: 600; }
.btn-sm { padding: 5px 11px; font-size: .83rem; }

.btn-icon-only {
    padding: 7px;
    width: 35px; height: 35px;
    justify-content: center;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 21px;
}
.card-header {
    padding: 16px 19px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 13px;
}
.card-body { padding: 19px; }
.card-danger { border-color: rgba(192, 57, 43, .4); }
.card-title {
    font-size: .98rem;
    font-weight: 600;
    margin-bottom: 6px;
}
.card-text { color: var(--text-muted); font-size: .9rem; }

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(194px, 1fr));
    gap: 18px;
    margin-bottom: 21px;
}
.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 19px;
    box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
    font-size: .8rem;
    color: var(--text-muted);
    margin-bottom: 7px;
}
.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -.5px;
    line-height: 1.1;
}
.stat-card .stat-note {
    margin-top: 8px;
    font-size: .78rem;
    color: var(--text-muted);
    line-height: 1.35;
}
.stat-card.link {
    display: block;
    color: var(--text);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.stat-card.link:hover {
    text-decoration: none;
    border-color: var(--brand);
    box-shadow: var(--shadow);
}
.stat-card.link .stat-label { display: flex; align-items: center; gap: 6px; }
.stat-card.link .stat-label .arrow { color: var(--brand); }
.stat-card.pulse { border-left: 3px solid var(--amber); }

/* ---------- Process steps (step-by-step guide) ---------- */
.process {
    display: grid;
    gap: 10px;
}
.process-step {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px 18px;
    box-shadow: var(--shadow-sm);
}
.process-step .process-num {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: var(--brand-text);
    font-size: .95rem;
    font-weight: 700;
}
.process-step .process-num.done { background: var(--green); }
.process-body { min-width: 0; }
.process-step h3 { font-size: 1rem; font-weight: 600; margin-bottom: 3px; }
.process-step p { font-size: .9rem; color: var(--text); }
.process-actor {
    display: block;
    margin-top: 7px;
    font-size: .8rem;
    font-weight: 500;
color: var(--text-muted);
}

/* ---------- Install steps (PWA setup guide) ---------- */
.inst-steps {
    margin: 4px 0 0;
    padding-left: 20px;
    display: grid;
    gap: 8px;
    font-size: .9rem;
    line-height: 1.5;
}
.inst-steps li {
    padding-left: 2px;
}
.inst-steps li strong {
    font-weight: 600;
}

/* ---------- Tables ---------- */
.table-wrap {
    overflow-x: auto;
    border-radius: 0 0 var(--radius) var(--radius);
}
.table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
    font-size: .95rem;
}
.table th {
    text-align: left;
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--text-muted);
    background: var(--bg-subtle);
    padding: 13px 17px;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
    white-space: nowrap;
}
.table th .th-sub {
    font-weight: 500;
    color: var(--text-light);
    letter-spacing: .3px;
}
.table th.col-name { min-width: 150px; }
.table td.col-name { white-space: nowrap; padding-right: 22px; }
.table td {
    padding: 13px 17px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table .empty-row { text-align: center; color: var(--text-muted); padding: 30px; }
.table .table-desc { white-space: normal; min-width: 260px; max-width: 420px; line-height: 1.45; color: var(--text); }
.table td.col-client { min-width: 300px; max-width: 380px; white-space: normal; line-height: 1.45; color: var(--text); }
.table .cell-muted { color: var(--text-muted); font-size: .85rem; }
.table .cell-nowrap { white-space: nowrap; }
.table .cell-sub { display: block; margin-top: 2px; font-size: .78rem; color: var(--text-light); }
.table .row-link { cursor: pointer; position: relative; }
.table .row-link:hover { background: var(--bg-hover); }
.table .row-link .cell-link { color: var(--brand); font-weight: 600; text-decoration: none; }
.table .row-link:hover .cell-link { text-decoration: underline; }
.table .row-link td:last-child { position: relative; }
.table .row-link td:last-child::after {
    content: '›';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1.15rem;
    line-height: 1;
    opacity: 0;
    transition: opacity .12s ease, transform .12s ease;
}
.table .row-link:hover td:last-child::after { opacity: 1; transform: translate(2px, -50%); }

/* ---------- Badges / pills ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .2px;
    line-height: 1.6;
    white-space: nowrap;
}
.badge-blue    { background: var(--blue-bg); color: var(--brand-hover); }
.badge-green   { background: var(--green-bg); color: var(--green); }
.badge-red     { background: var(--red-bg);   color: var(--red); }
.badge-amber   { background: var(--amber-bg); color: var(--amber); }
.badge-gray    { background: var(--gray-bg);  color: var(--gray); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: .85rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 7px;
}
.form-label .label-hint { color: var(--text-muted); font-weight: 400; }
.form-control {
    display: block;
    width: 100%;
    font-family: var(--font);
    font-size: .9rem;
    padding: 9px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(36, 144, 239, .15);
}
.form-control:disabled { background: var(--bg-subtle); color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 98px; }
select.form-control { padding-right: 33px; }

.form-hint { font-size: .8rem; color: var(--text-muted); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(229px, 1fr)); gap: 0 18px; }

/* Checkbox / remember-me */
.form-check {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    cursor: pointer;
    user-select: none;
    font-size: .9rem;
    color: var(--text);
    transition: background .12s ease, border-color .12s ease;
}
.form-check:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

/* Client mode toggle: Existing / New client */
.client-mode {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.form-check-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    cursor: pointer;
    user-select: none;
    font-size: .9rem;
    color: var(--text);
    transition: background .12s ease, border-color .12s ease;
}
.form-check-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}
.form-check-toggle input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand);
}
.form-check-toggle:has(input[type="radio"]:checked) {
    background: var(--bg-active);
    border-color: var(--brand);
    font-weight: 600;
}

/* ---------- Searchable combobox ---------- */
[hidden] { display: none !important; }
.combobox { position: relative; }
.combobox-input {
    padding-right: 32px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23687178' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}
.combobox-input[aria-expanded="true"] {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(36, 144, 239, .15);
}
.combobox-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 30;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 28px rgba(17, 24, 39, .12);
    max-height: 250px;
    overflow-y: auto;
}
.combobox-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: .88rem;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.combobox-option:hover,
.combobox-option.active { background: var(--bg-hover); }
.combobox-option.selected {
    background: var(--bg-active);
    color: var(--brand-hover);
    font-weight: 600;
}
.combobox-option-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combobox-option-phone {
    flex-shrink: 0;
    font-size: .78rem;
    color: var(--text-muted);
}
.combobox-add {
    margin-top: 4px;
    padding: 9px 10px 4px;
    border-top: 1px dashed var(--border-strong);
    color: var(--brand-hover);
    font-weight: 600;
    font-size: .85rem;
    cursor: pointer;
    user-select: none;
}
.combobox-add:hover,
.combobox-add.active { background: var(--bg-active); }
.combobox-clear {
    margin-bottom: 4px;
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px dashed var(--border-strong);
    color: var(--text-muted);
    font-size: .85rem;
    cursor: pointer;
    user-select: none;
}
.combobox-clear:hover,
.combobox-clear.active { color: var(--text); background: var(--bg-hover); }
.combobox-empty {
    padding: 10px;
    text-align: center;
    color: var(--text-muted);
    font-size: .85rem;
}
.form-check-input {
    width: 19px; height: 19px;
    flex: none;
    margin: 0;
    accent-color: var(--brand);
    cursor: pointer;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    margin-bottom: 19px;
    border: 1px solid transparent;
}
.alert-danger { background: var(--red-bg); color: var(--red); border-color: rgba(192,57,43,.25); }
.alert-success { background: var(--green-bg); color: var(--green); border-color: rgba(46,125,50,.25); }
.alert-info { background: var(--blue-bg); color: var(--brand-hover); border-color: rgba(36,144,239,.25); }
.alert a { font-weight: 600; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); }
.small { font-size: .84rem; }
.mb-1 { margin-bottom: 7px; }
.mb-2 { margin-bottom: 13px; }
.mb-3 { margin-bottom: 19px; }
.mt-1 { margin-top: 7px; }
.mt-2 { margin-top: 13px; }
.mt-3 { margin-top: 19px; }
.txt-right { text-align: right; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 13px; }
.grow { flex: 1; }
.max-w-sm { max-width: 528px; }
.max-w-md { max-width: 616px; }

/* ---------- Work orders (Phase 4.4) ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 19px;
}
.filter-pill {
    padding: 6px 13px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: .83rem;
    color: var(--text);
    background: var(--bg-surface);
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.filter-pill:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
    color: var(--text);
    text-decoration: none;
}
.filter-pill.active {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--brand-text);
}
.detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
    gap: 19px;
    align-items: start;
    margin-bottom: 19px;
}
.stack { display: flex; flex-direction: column; gap: 19px; min-width: 0; }
.detail-grid.split { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kv-row {
    display: flex;
    gap: 13px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
}
.kv-row:last-child { border-bottom: none; }
.kv-key {
    width: 105px;
    flex: none;
    color: var(--text-muted);
    font-size: .82rem;
    padding-top: 1px;
}
.kv-val { font-size: .9rem; word-break: break-word; }
.description-text {
    margin: 0;
    color: var(--text);
    font-size: .9rem;
    line-height: 1.55;
    white-space: pre-line;
}
.inline-form { display: inline-block; }
.workflow-stage {
    font-size: .9rem;
    color: var(--text-muted);
    margin-bottom: 13px;
}
.workflow-stage strong { color: var(--text); }
.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}
.timeline {
    padding: 8px 19px;
}
.timeline-item {
    position: relative;
    display: flex;
    gap: 13px;
    padding: 12px 0 12px 15px;
    border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: 0; top: 20px; bottom: -13px;
    width: 2px;
    background: var(--border);
}
.timeline-item:last-child::before { bottom: auto; height: 20px; }
.timeline-item .badge { align-self: flex-start; flex: none; margin-top: 1px; }
.timeline-body { min-width: 0; flex: 1; }
.timeline-detail { font-size: .9rem; color: var(--text); }
.timeline-meta {
    font-size: .78rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* ---------- Auth (login) page ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(160deg, #f2f6fb, var(--bg-page));
    padding: 12vh 22px 35px;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 35px 33px;
}
.auth-logo {
    display: flex;
    align-items: center;
    gap: 11px;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 6px;
}
.auth-logo .brand-dot {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--brand), #5aa7f0);
}
.auth-sub { color: var(--text-muted); font-size: .9rem; margin-bottom: 23px; }

/* ---------- Footer ---------- */
.footer {
    padding: 16px 31px;
    color: var(--text-light);
    font-size: .82rem;
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .content { padding: 19px 18px 32px; }
    .brand-inline { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 1rem; }
    .detail-grid, .detail-grid.split { grid-template-columns: 1fr; }
}

/* ---------- Service requests: mobile cards (replaces the wide table on phones) ---------- */
.req-table-desktop { display: block; }
.req-cards-mobile  { display: none; }

.req-card {
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
    padding: 13px 14px;
    cursor: pointer;
}
.req-card.empty {
    padding: 28px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: .9rem;
    cursor: default;
}
.req-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.req-card-title {
    min-width: 0;
    font-size: .94rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.35;
}
.req-card-title-sub {
    display: block;
    margin-top: 2px;
    font-size: .78rem;
    color: var(--text-light);
}
.req-card-badge { flex: none; }
.req-card-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 8px;
}
.req-card-key {
    flex: none;
    width: 66px;
    font-size: .74rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .3px;
}
.req-card-val {
    min-width: 0;
    flex: 1;
    font-size: .88rem;
    color: var(--text);
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
}
.req-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    font-size: .76rem;
    color: var(--text-light);
}
.req-card-assigned {
    min-width: 0;
    flex: 1;
    color: var(--text-muted);
}
.req-card-assigned b { color: var(--text); font-weight: 600; }
.req-card-wo {
    flex: none;
    color: var(--brand);
    font-weight: 600;
    text-decoration: none;
}
.req-card-wo:hover { text-decoration: underline; }
.req-card-date { flex: none; }

@media (max-width: 640px) {
    .req-table-desktop { display: none; }
    .req-cards-mobile  { display: block; }
    .client-mode { grid-template-columns: 1fr; }
    .filter-pill { padding: 8px 14px; font-size: .86rem; }
}
/* ---------- Work order discussion (chat) ---------- */
.disc-thread {
    display: flex; flex-direction: column; gap: 10px;
    padding: 2px 26px 16px 2px;
    max-height: 600px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(127, 142, 160, .5) transparent;
}
.disc-thread::-webkit-scrollbar { width: 8px; }
.disc-thread::-webkit-scrollbar-track { background: transparent; }
.disc-thread::-webkit-scrollbar-thumb {
    background: rgba(127, 142, 160, .5);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
.disc-msg {
    max-width:  85%;
    padding:  10px 12px;
    border-radius:  12px;
    background: var(--bg-subtle);
    border:  1px solid var(--border);
    font-size: .92rem;
    line-height: 1.45;
    min-width: 180px;
}
.disc-msg-me {
    align-self: flex-end;
    background: var(--bg-active);
    border-color: var(--brand);
}
.disc-msg-them { align-self: flex-start; }
.disc-msg-head { font-weight: 600; font-size: .8rem; color: var(--text-muted); margin-bottom: 3px; }
.disc-msg-body { word-wrap: break-word; white-space: pre-wrap; }
.disc-msg-meta { font-size: .72rem; color: var(--text-light); margin-top: 4px; display: flex; align-items: center; justify-content: flex-end; gap: 5px; line-height: 1; }
.disc-msg-status { display: inline-flex; align-items: center; line-height: 0; }
.disc-msg-status svg { display: block; }
.disc-msg-tick { width: 15px; height: 12px; color: var(--text-light); }
.disc-msg-tick-clock { width: 13px; height: 13px; opacity: .55; }
.disc-msg-tick-err { width: 15px; height: 15px; color: #dc3545; }
.disc-msg-status.seen .disc-msg-tick { color: var(--brand); }
.disc-msg-status.sending .disc-msg-tick { opacity: .55; }
.disc-msg-status.fail { cursor: pointer; }
.disc-msg-photo {
    display: block;
    width: min(340px, 100%);
    max-height: 480px;
    object-fit: contain;
    border-radius: 8px;
    margin: 6px 0;
    cursor: zoom-in;
    background: var(--bg-page);
}
.disc-photo-link { display: block; text-decoration: none; cursor: zoom-in; }

/* Full-screen photo viewer (in-app, no new tab — WhatsApp-style) */
.photo-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,.95);
    display: none;
    align-items: center; justify-content: center;
    padding: 0;
}
.photo-overlay.open { display: flex; }
.photo-overlay img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
.photo-close {
    position: absolute; top: 4px; right: 4px; z-index: 2;
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(0,0,0,.45); border: none; color: #fff;
    font-size: 1.4rem; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.photo-close:hover { background: rgba(255,255,255,.25); color: #000; }
.disc-older-wrap { text-align: center; }
.disc-older {
    margin: 2px 0 6px;
    padding: 6px 16px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--brand);
    font-size: .85rem;
    cursor: pointer;
}
.disc-form {
    margin-top:  12px; padding-top: 12px; border-top:  1px solid var(--border);
    display: flex; gap: 10px; align-items: flex-end;
}
.disc-input {
    flex:  1; resize: none;
    min-height:  40px;
    padding:  9px 12px;
    border:  1px solid var(--border-strong);
    border-radius:  8px;
    font-family: inherit; font-size: .92rem;
    line-height:  1.4;
    outline: none;
    box-sizing: border-box;
}
.disc-input:focus { border-color: var(--brand); box-shadow:  0 0 0 3px rgba(36, 144, 239, .12); }
.disc-send { flex: none; padding: 9px 18px; align-self: stretch; }

/* ---------- Notification bell (web) ---------- */
.topbar-notif { position: relative; margin-left: auto; }
.topbar-bell {
    display: flex; align-items: center; justify-content: center;
    width:  36px; height:  36px;
    background: none; border: none; cursor: pointer;
    border-radius:  50%;
    color: var(--text-muted);
    position: relative;
}
.topbar-bell:hover { background: var(--bg-hover); color: var(--text); }
.topbar-bell svg { width:  21px; height:  21px; stroke: currentColor; fill: none; stroke-width:  2; stroke-linecap: round; }
.notif-dot {
    position: absolute; top:  2px; right:  2px;
    min-width:  18px; height:  18px;
    padding:  0 4px;
    background: var(--red); color: #ffffff;
    font-size: .68rem; font-weight: 700; line-height: 1;
    border-radius:  10px;
    display: flex; align-items: center; justify-content: center;
    border:  2px solid var(--bg-surface);
}
.notif-menu {
    position: absolute; top:  44px; right:  0; z-index:  60;
    width:  310px; max-width:  85vw;
    background: var(--bg-surface);
    border:  1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.notif-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: .9rem;
}
.notif-clear {
    border: none; background: none; cursor: pointer;
    color: var(--brand); font-size: .8rem; font-weight: 500;
}
.notif-clear:hover { text-decoration: underline; }
.notif-list { max-height:  340px; overflow-y: auto; }
.notif-item {
    display: block; padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-decoration: none; color: var(--text);
}
.notif-item.unseen { background: var(--bg-active); }
.notif-item:hover { background: var(--bg-hover); }
.notif-item:last-child { border-bottom: none; }
.notif-body { font-size: .85rem; line-height: 1.4; margin-bottom: 3px; }
.notif-meta { font-size: .72rem; color: var(--text-light); }
.notif-list .empty { padding: 12px; text-align: center; color: var(--text-light); font-size: .85rem; }

/* ---------- In-page confirm modal (replaces the browser confirm dialog) ---------- */
.confirm-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(15, 20, 25, .45);
    display: none; align-items: center; justify-content: center;
    padding: 20px;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.confirm-overlay.open { display: flex; }
.confirm-box {
    width: 100%; max-width: 400px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(15, 20, 25, .18);
    padding: 24px 22px 18px;
    text-align: center;
}
.confirm-icon {
    width: 54px; height: 54px; margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--amber-bg); color: var(--amber);
    display: flex; align-items: center; justify-content: center;
}
.confirm-title {
    font-size: 1.1rem; font-weight: 700; color: var(--text);
    margin-bottom: 6px; letter-spacing: -.2px;
}
.confirm-msg {
    font-size: .92rem; color: var(--text-muted); line-height: 1.5;
    margin-bottom: 18px;
}
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; padding: 10px 14px; font-size: .92rem; }
#confirmOk { background: var(--brand); border-color: var(--brand); color: #fff; }
#confirmOk:hover { background: var(--brand-hover); color: #fff; }
#confirmOk.confirm-danger { background: var(--red); border-color: var(--red); color: #fff; }
#confirmOk.confirm-danger:hover { background: #a83226; }
.confirm-overlay .confirm-actions .btn + .btn { margin-left: 0; }
