/* =========================================================================
   Dotinker — internal app shell (admin + employee portal)
   Dark sidebar in brand navy/green, light content area for readable
   data-dense tables and forms.
   ========================================================================= */

body.app { background: var(--paper-soft); min-height: 100vh; }

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

/* Sidebar -------------------------------------------------------------------- */
.app-sidebar {
    width: 250px; flex-shrink: 0;
    background: var(--navy-900); color: var(--text-on-dark);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.app-sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 22px 22px 18px; font-family: var(--font-mono); font-weight: 700; }
.app-sidebar .brand img { height: 30px; }
.app-sidebar nav { padding: 10px 14px; flex: 1; }
.app-sidebar .nav-section-label { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: .08em; color: rgba(243,243,243,0.35); padding: 16px 12px 6px; }
.app-sidebar a.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    font-size: 0.89rem; color: var(--text-on-dark-muted); font-weight: 500;
    margin-bottom: 2px;
}
.app-sidebar a.nav-link .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.5; flex-shrink: 0; }
.app-sidebar a.nav-link:hover { background: rgba(255,255,255,0.06); color: var(--text-on-dark); }
.app-sidebar a.nav-link.active { background: var(--brand-green); color: var(--navy-900); font-weight: 700; }
.app-sidebar a.nav-link.active .dot { background: var(--navy-900); opacity: 1; }
.app-sidebar .sidebar-foot { padding: 16px 22px; border-top: 1px solid var(--line-on-dark); font-size: 0.78rem; color: var(--text-on-dark-muted); }

/* Main column ------------------------------------------------------------------ */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
    height: 70px; flex-shrink: 0; background: var(--paper);
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.app-topbar .page-title { font-family: var(--font-display); font-size: 1.3rem; }
.app-topbar .top-actions { display: flex; align-items: center; gap: 18px; }
.icon-btn { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); display: flex; align-items: center; justify-content: center; }
.icon-btn .ping { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--paper); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user .name { font-size: 0.86rem; font-weight: 600; }
.topbar-user .role { font-size: 0.72rem; color: var(--ink-500); }
.topbar-user .avatar-circle { overflow: hidden; border-radius: 50%;}
.mobile-menu-btn { display: none; background: none; border: none; }

.app-content { padding: 28px; flex: 1; }
.app-content .content-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.app-content .content-head h1 { font-size: 1.5rem; margin: 0; }
.app-content .content-head .sub { color: var(--ink-500); font-size: 0.88rem; margin-top: 4px; }

@media (max-width: 980px) {
    .app-sidebar { position: fixed; z-index: 200; transform: translateX(-100%); transition: transform .2s ease; }
    .app-sidebar.open { transform: translateX(0); }
    .mobile-menu-btn { display: flex; }
    .app-content { padding: 18px; }
}

/* Stat cards ------------------------------------------------------------------------ */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
@media (max-width: 980px) { .stat-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .stat-cards { grid-template-columns: 1fr; } }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; }
.stat-card .stat-top { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-card .stat-icon { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 700; font-size: 0.85rem; }
.stat-card .stat-icon.green { background: rgba(124,241,4,0.16); color: #4C9200; }
.stat-card .stat-icon.blue { background: rgba(45,98,224,0.12); color: var(--brand-blue); }
.stat-card .stat-icon.purple { background: rgba(164,167,255,0.24); color: #6367CC; }
.stat-card .stat-icon.yellow { background: rgba(255,243,110,0.32); color: #9C8B00; }
.stat-card .stat-num { font-family: var(--font-display); font-size: 1.9rem; margin-top: 14px; }
.stat-card .stat-label { font-size: 0.82rem; color: var(--ink-500); }
.stat-card .stat-delta { font-size: 0.76rem; font-weight: 600; }
.stat-card .stat-delta.up { color: var(--ok); }
.stat-card .stat-delta.down { color: var(--danger); }

/* Panels / cards ---------------------------------------------------------------------- */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); }
.panel .panel-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.panel .panel-head h3 { margin: 0; font-size: 1rem; font-family: var(--font-body); font-weight: 700; }
.panel .panel-body { padding: 22px; }
.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 980px) { .two-col { grid-template-columns: 1fr; } }

/* Tables --------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); font-weight: 700; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data-table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data-table tbody tr:hover { background: var(--paper-soft); }
table.data-table tbody tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 8px; }
.row-actions a, .row-actions button { font-size: 0.78rem; font-weight: 600; padding: 5px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--paper); }
.row-actions a:hover { border-color: var(--brand-green); color: var(--brand-green-dark); }
.row-actions .danger:hover { border-color: var(--danger); color: var(--danger); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-500); }
.empty-state .glyph { font-family: var(--font-display); font-size: 2rem; color: var(--line); margin-bottom: 10px; }

.person-cell { display: flex; align-items: center; gap: 10px; }
.person-cell .name { font-weight: 600; }
.person-cell .sub { font-size: 0.76rem; color: var(--ink-500); }

/* Filters / toolbars ---------------------------------------------------------------------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.toolbar .input, .toolbar select.input { width: auto; min-width: 160px; padding: 9px 12px; }
.tab-row { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.tab-row a { padding: 10px 16px; font-size: 0.86rem; font-weight: 600; color: var(--ink-500); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab-row a.active { color: var(--navy-900); border-color: var(--brand-green); }

/* Kanban board ------------------------------------------------------------------------------- */
.kanban-board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 16px; overflow-x: auto; }
@media (max-width: 900px) { .kanban-board { grid-template-columns: 1fr; } }
.kanban-col { background: var(--paper-soft); border-radius: var(--radius-md); padding: 14px; min-height: 120px; }
.kanban-col .col-head { display: flex; justify-content: space-between; align-items: center; font-size: 0.82rem; font-weight: 700; padding: 4px 6px 14px; }
.kanban-col .col-head .count { font-family: var(--font-mono); color: var(--ink-500); font-weight: 500; }
.kanban-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 14px; margin-bottom: 10px; }
.kanban-card:hover { border-color: var(--brand-green); }
.kanban-card .title { font-size: 0.87rem; font-weight: 600; margin-bottom: 8px; }
.kanban-card .meta-row { display: flex; justify-content: space-between; align-items: center; }
.kanban-card .due { font-size: 0.72rem; color: var(--ink-500); font-family: var(--font-mono); }

/* Timeline / activity feed ---------------------------------------------------------------------- */
.activity-feed .item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-feed .item:last-child { border-bottom: none; }
.activity-feed .bullet { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-green); margin-top: 6px; flex-shrink: 0; }
.activity-feed .desc { font-size: 0.86rem; }
.activity-feed .when { font-size: 0.74rem; color: var(--ink-500); font-family: var(--font-mono); }

/* Letter / document preview ------------------------------------------------------------------------ */
.letter-preview { background: white; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 46px; font-family: 'Times New Roman', serif; max-width: 720px; margin: 0 auto; color: #1a1a1a; }
.letter-preview .letterhead { display: flex; align-items: center; gap: 12px; border-bottom: 3px solid var(--brand-green); padding-bottom: 16px; margin-bottom: 30px; }
.letter-preview .letterhead img { height: 40px; }
.letter-preview .ref { text-align: right; font-size: 0.8rem; color: #666; margin-bottom: 20px; }

/* Login / auth screens ------------------------------------------------------------------------------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .auth-shell { grid-template-columns: 1fr; } }
.auth-visual { background: var(--navy-900); color: var(--text-on-dark); padding: 60px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-visual .grid-bg { position: absolute; inset: 0; opacity: 0.5; background-image: linear-gradient(var(--line-on-dark) 1px, transparent 1px), linear-gradient(90deg, var(--line-on-dark) 1px, transparent 1px); background-size: 42px 42px; }
.auth-visual > * { position: relative; }
.auth-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-box { width: 100%; max-width: 380px; }
.auth-box .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; font-family: var(--font-mono); font-weight: 700; }
.auth-box .brand img { height: 32px; }

/* Month calendar (holidays / leave / birthdays) ---------------------------------------------------------- */
.calendar-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-nav h3 { margin: 0; font-family: var(--font-body); font-weight: 700; font-size: 1.05rem; }
.calendar-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; font-size: 0.78rem; color: var(--ink-500); }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.calendar-legend .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.calendar-legend .dot.holiday { background: var(--brand-green); }
.calendar-legend .dot.leave { background: var(--brand-yellow); }
.calendar-legend .dot.birthday { background: var(--brand-purple); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-grid .dow { text-align: center; font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; color: var(--ink-500); padding-bottom: 6px; }
.calendar-cell { min-height: 84px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; background: var(--paper); display: flex; flex-direction: column; gap: 3px; }
.calendar-cell.empty { background: transparent; border-color: transparent; }
.calendar-cell.today { border-color: var(--brand-green); border-width: 2px; padding: 5px; }
.calendar-cell .date-num { font-size: 0.78rem; font-weight: 600; color: var(--ink-700); }
.calendar-cell .cal-marker { font-size: 0.66rem; padding: 2px 5px; border-radius: 5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-cell .cal-marker.holiday { background: rgba(124,241,4,0.18); color: #3F7A00; }
.calendar-cell .cal-marker.leave { background: rgba(255,243,110,0.45); color: #7A6900; }
.calendar-cell .cal-marker.birthday { background: rgba(164,167,255,0.28); color: #4B4FCC; }
@media (max-width: 700px) {
    .calendar-cell { min-height: 56px; font-size: 0.72rem; }
    .calendar-cell .cal-marker { display: none; }
    .calendar-cell.has-marker::after { content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--brand-green); }
}

/* Signature pad --------------------------------------------------------------------------------------- */
.signature-preview { height: 70px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 14px; display: inline-flex; align-items: center; margin-bottom: 12px; }
.signature-preview img { max-height: 100%; max-width: 220px; }
#signaturePad { border: 1.5px dashed var(--line); border-radius: var(--radius-sm); background: #fff; touch-action: none; cursor: crosshair; display: block; width: 100%; max-width: 400px; height: 150px; }

/* Misc utility --------------------------------------------------------------------------------------- */
.progress-bar { height: 8px; background: var(--paper-soft); border-radius: 99px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--brand-green); }
.rating-stars { color: var(--brand-yellow); filter: saturate(1.4) brightness(0.85); }
.notif-dropdown { position: absolute; right: 0; top: 52px; width: 320px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-md); display: none; z-index: 50; max-height: 400px; overflow-y: auto; }
.notif-dropdown.open { display: block; }
.notif-dropdown .n-item { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 0.83rem; }
.notif-dropdown .n-item.unread { background: rgba(124,241,4,0.06); }
.user-menu-wrap { position: relative; }

/* =========================================================================
   Billing — quote & invoice editors, document preview, payment panels
   ========================================================================= */

/* Responsive field grid used across the billing forms ----------------------- */
.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 18px; }
.doc-form .field { margin-bottom: 16px; }

/* Key/value rows in the side panels ----------------------------------------- */
.kv-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; font-size: 0.86rem; }

/* Compact clickable summary rows (linked invoices, payments) ------------------ */
.mini-row {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--line);
}
.mini-row:last-child { border-bottom: none; }
a.mini-row:hover { background: var(--paper-soft); }

/* Line-item editor ------------------------------------------------------------ */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th {
    text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--ink-500); font-weight: 700; padding: 0 8px 8px; white-space: nowrap;
}
.items-table td { padding: 4px 8px 4px 0; vertical-align: middle; }
.items-table td:first-child { padding-left: 0; }
.items-table .input { margin: 0; padding: 9px 11px; }
.items-table .line-amount {
    font-variant-numeric: tabular-nums; font-size: 0.85rem; text-align: right;
    white-space: nowrap; color: var(--ink-700);
}
.row-remove {
    width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line);
    background: var(--paper); color: var(--ink-500); font-size: 1.1rem; line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
.row-remove:hover { border-color: var(--danger); color: var(--danger); }

@media (max-width: 760px) {
    .items-table thead { display: none; }
    .items-table, .items-table tbody, .items-table tr, .items-table td { display: block; width: 100%; }
    .items-table tr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; }
    .items-table td { padding: 4px 0; }
    .items-table .line-amount { text-align: left; font-weight: 700; }
    .items-table .line-amount::before { content: 'Amount: '; color: var(--ink-500); font-family: var(--font-body); font-weight: 400; }
}

/* Running totals under the line items ------------------------------------------ */
.items-summary { margin-top: 18px; margin-left: auto; max-width: 320px; font-size: 0.88rem; }
.items-summary .row { display: flex; justify-content: space-between; padding: 6px 0; color: var(--ink-500); }
.items-summary .row strong { color: var(--ink-900); font-variant-numeric: tabular-nums; }
.items-summary .row.grand {
    border-top: 2px solid var(--navy-900); margin-top: 6px; padding-top: 10px;
    font-size: 1rem; color: var(--ink-900); font-weight: 700;
}

/* Billing-type picker (percentage vs itemised) ----------------------------------- */
.billing-type-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .billing-type-picker { grid-template-columns: 1fr; } }
.billing-type-picker .type-option {
    display: flex; gap: 11px; align-items: flex-start; cursor: pointer;
    border: 1.5px solid var(--line); border-radius: var(--radius-md); padding: 15px 16px;
    transition: border-color .15s ease, background .15s ease;
}
.billing-type-picker .type-option:hover { border-color: var(--brand-green-dark); }
.billing-type-picker .type-option.selected { border-color: var(--brand-green); background: rgba(124,241,4,0.06); }
.billing-type-picker .type-option input { margin-top: 3px; accent-color: var(--brand-green-dark); flex-shrink: 0; }
.billing-type-picker .type-option strong { display: block; font-size: 0.89rem; margin-bottom: 3px; }
.billing-type-picker .type-option span { font-size: 0.79rem; color: var(--ink-500); line-height: 1.45; }

/* Percentage helpers --------------------------------------------------------------- */
.percent-presets { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--line); background: var(--paper); border-radius: 99px;
    padding: 5px 13px; font-size: 0.78rem; font-weight: 600; color: var(--ink-700);
}
.chip:hover { border-color: var(--brand-green); color: var(--brand-green-dark); background: rgba(124,241,4,0.06); }
.percent-callout {
    margin-top: 14px; padding: 13px 15px; border-radius: var(--radius-sm);
    background: rgba(124,241,4,0.08); border: 1px solid rgba(124,241,4,0.28);
    font-size: 0.85rem; color: var(--ink-700);
}
.balance-figure .amount { font-family: var(--font-display); font-size: 2rem; line-height: 1.1; margin-top: 2px; }

/* On-screen quote / invoice document ------------------------------------------------- */
.doc-preview { background: var(--paper); color: var(--ink-900); font-size: 0.88rem; }
.doc-preview-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; padding-bottom: 16px; border-bottom: 3px solid var(--brand-green); }
.doc-brand { display: flex; align-items: center; gap: 11px; }
.doc-brand img { height: 36px; width: auto; }
.doc-brand .co { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.1; }
.doc-brand .tag { font-size: 0.72rem; color: var(--ink-500); font-family: var(--font-mono); }
.doc-label { text-align: right; }
.doc-label .kind { font-family: var(--font-display); font-size: 1.5rem; line-height: 1; }
.doc-label .num { font-family: var(--font-mono); font-size: 0.82rem; color: var(--ink-500); margin-top: 4px; }

.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; padding: 20px 0; }
@media (max-width: 640px) { .doc-parties { grid-template-columns: 1fr; gap: 18px; } }
.doc-party-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-500); font-weight: 700; margin-bottom: 5px; }
.doc-party-name { font-weight: 700; font-size: 0.95rem; margin-bottom: 2px; }
.doc-party-line { font-size: 0.8rem; color: var(--ink-500); line-height: 1.5; }

.doc-meta { display: flex; flex-wrap: wrap; gap: 26px; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.doc-meta > div { display: flex; flex-direction: column; gap: 3px; }
.doc-meta span { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); font-weight: 700; }
.doc-meta strong { font-size: 0.88rem; }

.doc-title { margin: 20px 0 6px; font-family: var(--font-body); font-weight: 700; font-size: 1.05rem; }
.doc-summary { color: var(--ink-500); font-size: 0.85rem; margin: 0 0 16px; }

table.doc-items { width: 100%; border-collapse: collapse; margin: 14px 0 0; font-size: 0.85rem; }
table.doc-items th { background: var(--navy-900); color: var(--text-on-dark); text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: .05em; padding: 9px 12px; font-weight: 700; }
table.doc-items th:first-child { border-radius: 6px 0 0 6px; }
table.doc-items th:last-child { border-radius: 0 6px 6px 0; }
table.doc-items td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.doc-items .r { text-align: right; white-space: nowrap; }

.doc-totals { margin: 18px 0 0 auto; max-width: 320px; }
.doc-totals .row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-size: 0.86rem; color: var(--ink-500); }
.doc-totals .row strong { color: var(--ink-900); font-variant-numeric: tabular-nums; }
.doc-totals .row.grand { background: var(--brand-green); color: var(--navy-900); font-weight: 700; padding: 11px 14px; border-radius: var(--radius-sm); margin-top: 8px; font-size: 0.98rem; }
.doc-totals .row.grand strong { color: var(--navy-900); }
.doc-totals .row.balance { border-top: 2px solid var(--navy-900); margin-top: 6px; padding-top: 10px; font-weight: 700; color: var(--ink-900); }

.doc-note { margin-top: 22px; font-size: 0.83rem; color: var(--ink-700); line-height: 1.6; }
.doc-note-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-500); font-weight: 700; margin-bottom: 5px; }
.doc-payment-line { display: flex; justify-content: space-between; gap: 14px; padding: 4px 0; }

/* Rich text — shared by the editor surface and the rendered document, so
   what you type looks the way the quote will. */
.rich-content { line-height: 1.6; }
.rich-content > :first-child { margin-top: 0; }
.rich-content h1, .rich-content h2, .rich-content h3, .rich-content h4 { font-family: var(--font-body); font-weight: 700; letter-spacing: 0; line-height: 1.3; color: var(--ink-900); }
.rich-content h1 { font-size: 1.45rem; margin: 22px 0 10px; }
.rich-content h2 { font-size: 1.15rem; margin: 20px 0 8px; }
.rich-content h3 { font-size: 1rem; margin: 16px 0 6px; }
.rich-content h4 { font-size: 0.9rem; margin: 14px 0 4px; }
.rich-content p { margin: 0 0 10px; }
.rich-content ul, .rich-content ol { margin: 0 0 10px; padding-left: 24px; }
.rich-content ul { list-style: disc; }
.rich-content ul ul { list-style: circle; }
.rich-content ol { list-style: decimal; }
.rich-content li { margin: 2px 0; }
.rich-content table { width: 100%; border-collapse: collapse; margin: 6px 0 14px; font-size: 0.85rem; }
.rich-content th, .rich-content td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; min-width: 60px; }
.rich-content th { background: var(--paper-soft); font-weight: 700; }
.rich-content hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.rich-content blockquote { margin: 0 0 12px; padding: 2px 0 2px 14px; border-left: 3px solid #c8cdd4; color: var(--ink-700); }
.rich-content blockquote > :last-child { margin-bottom: 0; }
.rich-content a { color: var(--brand-blue); text-decoration: underline; }

.doc-rich { margin: 14px 0 18px; font-size: 0.86rem; color: var(--ink-700); overflow-x: auto; }

/* WordPress-style editor (admin/includes/rich-editor.php) — the classic
   editor's light grey chrome, so it feels like the one people already know. */
.wp-editor { --wp-border: #dcdcde; --wp-bar: #f6f7f7; --wp-icon: #50575e; --wp-hover: #1d2327; position: relative; }
.wp-editor [hidden] { display: none !important; }
.wp-editor-tabs { display: flex; justify-content: flex-end; gap: 4px; margin-bottom: -1px; position: relative; z-index: 1; }
.wp-tab {
    padding: 5px 12px 6px; font-size: 13px; line-height: 1.5; color: #50575e; background: #ebebeb;
    border: 1px solid var(--wp-border); border-radius: 3px 3px 0 0; cursor: pointer;
}
.wp-tab:hover { color: var(--wp-hover); }
.wp-tab.is-active { background: var(--wp-bar); border-bottom-color: var(--wp-bar); color: #2c3338; }
.wp-editor.is-text .wp-tab.is-active { background: var(--wp-bar); }

.wp-editor-frame { position: relative; border: 1px solid var(--wp-border); background: #fff; }

.wp-toolbar { background: var(--wp-bar); border-bottom: 1px solid var(--wp-border); padding: 3px; }
.wp-toolbar-row { display: flex; flex-wrap: wrap; align-items: center; gap: 1px; }
.wp-toolbar-row + .wp-toolbar-row { margin-top: 2px; }
.wp-toolbar-spacer { flex: 1; }
.wp-btn {
    display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 4px;
    border: 1px solid transparent; border-radius: 2px; background: transparent; color: var(--wp-icon); cursor: pointer;
}
.wp-btn:hover { color: var(--wp-hover); background: #fafafa; border-color: #8c8f94; box-shadow: inset 0 1px 0 #fff, 0 1px 0 rgba(0, 0, 0, .08); }
.wp-btn.is-active { background: #ebebeb; border-color: #8c8f94; color: var(--wp-hover); box-shadow: inset 0 2px 5px -3px rgba(0, 0, 0, .3); }
.wp-btn svg { width: 20px; height: 20px; fill: currentColor; }
.wp-btn svg .s { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.wp-btn svg .s-thick { stroke-width: 2.4; }
.wp-btn svg .s-inverse { stroke: #fff; }
.wp-btn svg .inverse { fill: #fff; }
.wp-btn svg text { font-family: var(--font-body); font-weight: 700; fill: currentColor; }
.wp-btn-text { font-size: 12.5px; padding: 0 8px; }
.wp-glyph { font-family: var(--font-body); font-size: 16px; line-height: 1; }
.wp-glyph-b { font-weight: 800; }
.wp-glyph-i { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 17px; }
.wp-glyph-u { text-decoration: underline; text-underline-offset: 2px; }
.wp-glyph-strike { font-size: 11px; text-decoration: line-through; letter-spacing: .02em; }
.wp-glyph-color { display: inline-flex; flex-direction: column; align-items: center; font-weight: 600; font-size: 15px; }
.wp-color-bar { display: block; width: 16px; height: 3px; margin-top: 2px; }

.wp-listbox {
    height: 30px; width: 130px; margin-right: 4px; padding: 0 6px; font-size: 13px; color: #2c3338; background: #fff;
    border: 1px solid #ddd; border-radius: 2px; box-shadow: 0 1px 1px -1px rgba(0, 0, 0, .2); cursor: pointer;
}
.wp-split { display: inline-flex; }
.wp-split .wp-split-main { min-width: 26px; padding: 0 2px 0 4px; }
.wp-split .wp-split-arrow { min-width: 16px; padding: 0 1px; }
.wp-split .wp-split-arrow svg { width: 10px; height: 10px; }

.wp-table-row { background: #f0f6fc; margin: 3px -3px -3px; padding: 2px 3px; border-top: 1px solid var(--wp-border); }
.wp-table-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: #646970; margin: 0 6px 0 4px; }
.wp-table-hint { margin-left: auto; padding-right: 6px; font-size: 12px; color: #646970; }

.wp-quicktags { background: var(--wp-bar); border-bottom: 1px solid var(--wp-border); padding: 3px; display: flex; flex-wrap: wrap; gap: 2px; }
.wp-qt {
    min-height: 26px; padding: 0 8px; font: 13px/1 Consolas, Monaco, monospace; color: #2c3338; background: #f6f7f7;
    border: 1px solid #c3c4c7; border-radius: 3px; cursor: pointer;
}
.wp-qt:hover { background: #f0f0f1; border-color: #8c8f94; color: #1d2327; }
.wp-qt[data-rte-qt="b"] { font-weight: 700; }
.wp-qt[data-rte-qt="i"] { font-style: italic; }
.wp-qt[data-rte-qt="link"] { text-decoration: underline; }
.wp-qt[data-rte-qt="del"] { text-decoration: line-through; }

.wp-content { position: relative; }
.wp-surface { min-height: 300px; padding: 10px 14px; outline: none; font-size: 15px; color: #1d2327; }
.wp-source {
    display: block; width: 100%; min-height: 300px; padding: 10px 14px; border: 0; outline: none; resize: vertical;
    font: 13px/1.6 Consolas, Monaco, monospace; color: #2c3338; background: #fff;
}
.wp-editor.is-empty .wp-surface::before { content: attr(data-placeholder); position: absolute; color: #8c8f94; pointer-events: none; }

.wp-statusbar { min-height: 24px; padding: 2px 8px; border-top: 1px solid var(--wp-border); font-size: 12px; color: #50575e; background: #fff; }
.wp-crumb { padding: 0 2px; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.wp-crumb:hover { color: #2271b1; text-decoration: underline; }
.wp-editor.is-text .wp-statusbar { display: none; }
.wp-wordcount { padding: 4px 10px; font-size: 12px; color: #50575e; background: var(--wp-bar); border: 1px solid var(--wp-border); border-top: 0; }

.wp-pop {
    position: absolute; z-index: 30; padding: 8px; background: #fff; border: 1px solid var(--wp-border);
    border-radius: 2px; box-shadow: 0 3px 6px rgba(0, 0, 0, .15); max-width: calc(100% - 8px);
}
.wp-pop-link { display: flex; flex-wrap: wrap; gap: 6px; width: 340px; }
.wp-pop-input { flex: 1; min-width: 0; height: 32px; padding: 0 8px; font-size: 13px; border: 1px solid #8c8f94; border-radius: 3px; outline: none; }
.wp-pop-input:focus { border-color: #2271b1; box-shadow: 0 0 0 1px #2271b1; }
.wp-pop-apply { width: 34px; height: 32px; border: 0; border-radius: 3px; background: #2271b1; color: #fff; font-size: 15px; cursor: pointer; }
.wp-pop-error { flex-basis: 100%; font-size: 12px; color: #d63638; }
.wp-swatches { display: grid; grid-template-columns: repeat(8, 20px); gap: 3px; }
.wp-swatch { width: 20px; height: 20px; padding: 0; border: 1px solid rgba(0, 0, 0, .18); cursor: pointer; }
.wp-swatch:hover { outline: 2px solid #2271b1; outline-offset: 1px; }
.wp-pop-plain { display: block; width: 100%; margin-top: 8px; padding: 4px; font-size: 12px; background: #f6f7f7; border: 1px solid #c3c4c7; border-radius: 3px; cursor: pointer; }
.wp-charmap { display: grid; grid-template-columns: repeat(8, 30px); gap: 2px; }
.wp-char { width: 30px; height: 30px; font-size: 15px; background: #fff; border: 1px solid #e5e5e5; cursor: pointer; }
.wp-char:hover { background: #2271b1; color: #fff; border-color: #2271b1; }
.wp-pop-help { width: 320px; font-size: 13px; color: #2c3338; }
.wp-pop-help table { width: 100%; margin: 8px 0 6px; border-collapse: collapse; }
.wp-pop-help td { padding: 4px 0; border-bottom: 1px solid #f0f0f1; }
.wp-pop-help td:first-child { font-family: Consolas, Monaco, monospace; font-size: 12px; white-space: nowrap; padding-right: 12px; }
.wp-pop-help p { margin: 0; font-size: 12px; color: #646970; }

.wp-editor.is-fullscreen { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; padding: 10px; background: #fff; }
.wp-editor.is-fullscreen .wp-editor-frame { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.wp-editor.is-fullscreen .wp-content { flex: 1; overflow: auto; }
.wp-editor.is-fullscreen .wp-surface, .wp-editor.is-fullscreen .wp-source { min-height: 100%; }
.wp-editor.is-fullscreen .wp-surface { max-width: 860px; margin: 0 auto; }
html.wp-editor-fullscreen-open { overflow: hidden; }

@media (max-width: 640px) {
    .wp-table-hint { display: none; }
    .wp-listbox { width: 118px; }
}

@media print {
    .app-sidebar, .app-topbar, .content-head, .panel-head, .btn { display: none !important; }
    .app-content, .panel, .panel-body { padding: 0 !important; border: none !important; }
    .two-col { display: block !important; }
}

/* =========================================================================
   Attachments & comment threads (project / task views, all three portals)
   ========================================================================= */

.attachment-row { display: flex; align-items: flex-start; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.attachment-row:last-of-type { border-bottom: none; }
.attachment-row .glyph { font-size: 1.05rem; line-height: 1.4; flex-shrink: 0; width: 20px; text-align: center; }
.attachment-main { flex: 1; min-width: 0; }
.attachment-label { font-size: 0.87rem; font-weight: 600; word-break: break-word; }
.attachment-label:hover { color: var(--brand-green-dark); text-decoration: underline; }
.attachment-meta { font-size: 0.75rem; color: var(--ink-500); margin-top: 2px; }
.attachment-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.attach-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.attach-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.attach-tab {
    border: 1px solid var(--line); background: var(--paper); border-radius: 99px;
    padding: 5px 14px; font-size: 0.78rem; font-weight: 600; color: var(--ink-500);
}
.attach-tab.active { border-color: var(--brand-green); background: rgba(124,241,4,0.10); color: var(--ink-900); }
.attach-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.attach-row .input { flex: 1; min-width: 160px; margin: 0; }

.checkbox-row, .radio-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; }
.checkbox-row input, .radio-row input { accent-color: var(--brand-green-dark); }

/* Comment thread ------------------------------------------------------------- */
.comment { display: flex; gap: 11px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.comment:last-of-type { border-bottom: none; }
.comment-avatar { width: 34px; height: 34px; font-size: 0.72rem; flex-shrink: 0; overflow: hidden; border-radius: 50%; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 0.85rem; margin-bottom: 3px; }
.comment-when { font-size: 0.74rem; }
.comment-text { font-size: 0.87rem; line-height: 1.6; word-break: break-word; }
.comment.internal { background: var(--paper-soft); border-radius: var(--radius-sm); padding: 13px 14px; border-bottom: none; margin-bottom: 8px; }
.comment.from-client .comment-avatar { box-shadow: 0 0 0 2px var(--brand-yellow); }

.comment-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.comment-form textarea.input { min-height: 84px; }
.comment-visibility { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.comment-visibility .radio-row span { font-size: 0.8rem; color: var(--ink-500); }
.comment-visibility .radio-row strong { color: var(--ink-900); }

/* Kanban card extras ----------------------------------------------------------- */
.kanban-card .card-tags { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin-bottom: 7px; }
.kanban-card .card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; font-size: 0.72rem; color: var(--ink-500); }
.kanban-card .card-assignee { display: flex; align-items: center; gap: 5px; }
.kanban-card .card-assignee .avatar-circle { width: 20px; height: 20px; font-size: 0.56rem; overflow: hidden; border-radius: 50%; }
.kanban-card .card-count { font-family: var(--font-mono); }
.kanban-card.is-internal { border-left: 3px solid var(--ink-500); }

/* Client portal shell extras ---------------------------------------------------- */
.client-badge { margin: 0 14px 6px; padding: 12px 14px; border-radius: var(--radius-sm); background: rgba(124,241,4,0.10); border: 1px solid rgba(124,241,4,0.22); }
.client-badge .label { font-family: var(--font-mono); font-size: 0.62rem; text-transform: uppercase; letter-spacing: .1em; color: var(--brand-green); }
.client-badge .company { font-size: 0.87rem; font-weight: 700; color: var(--text-on-dark); margin-top: 3px; line-height: 1.3; }
.app-sidebar a.nav-link .nav-pill { margin-left: auto; background: var(--danger); color: #fff; border-radius: 99px; font-size: 0.68rem; font-weight: 700; padding: 1px 7px; }
.app-sidebar a.nav-link.active .nav-pill { background: var(--navy-900); color: var(--text-on-dark); }

/* Client project list ------------------------------------------------------------ */
.project-row { display: flex; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.project-row:last-child { border-bottom: none; }
.project-row:hover strong { color: var(--brand-green-dark); }

.project-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.project-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; display: block; }
.project-card:hover { border-color: var(--brand-green); box-shadow: var(--shadow-sm); }
.project-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.project-card-head h3 { margin: 0; font-family: var(--font-body); font-weight: 700; font-size: 1rem; line-height: 1.3; }
.project-card p { font-size: 0.83rem; margin: 0 0 14px; line-height: 1.55; }
.project-card-meta { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 9px; font-size: 0.76rem; color: var(--ink-500); }

/* Money in a stat card: the pixel display font has no rupee glyph, so amounts
   use the body face with tabular figures while plain counts keep the display font. */
.stat-card .stat-num.amount { font-family: var(--font-body); font-weight: 700; font-size: 1.5rem; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.balance-figure .amount { font-family: var(--font-body); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

/* Multi-currency ------------------------------------------------------------ */
/* `hidden` has to win over the display rules on fields and summary rows. */
.field[hidden], .items-summary .row[hidden] { display: none; }
.fx-equiv { font-size: 0.72rem; font-weight: 500; color: var(--ink-500); margin-top: 2px; font-variant-numeric: tabular-nums; }
.items-summary .row.home-equiv { font-size: 0.82rem; color: var(--ink-500); }
.items-summary .row.home-equiv strong { color: var(--ink-700); font-weight: 600; }
.rate-input { display: flex; align-items: center; gap: 10px; }
.rate-input .input { flex: 1; min-width: 0; }
.rate-input-label { white-space: nowrap; font-size: 0.86rem; font-weight: 600; color: var(--ink-700); }
.money-input { display: flex; gap: 8px; }
.money-input select.input { flex: 0 0 42%; min-width: 0; }
.money-input input.input { flex: 1; min-width: 0; }
.link-btn { padding: 0; border: 0; background: none; color: var(--brand-blue); font: inherit; text-decoration: underline; cursor: pointer; }

/* A grid column otherwise grows to fit its widest child, so a document
   preview pushed the whole page sideways on a phone. */
.two-col > * { min-width: 0; }
.doc-preview { overflow-x: auto; }
