/* ── GreenLight Frontend Dashboard ──────────────────────────────────────────────
   Scoped entirely under .gl-dash to avoid theme conflicts.
   Shell (sidebar + flat surfaces) matches CommercePilot — see CLAUDE.md
   "Design tokens" section for the shared conventions.
   ────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

.gl-dash {
    --td-ink:          #1e2535;
    --td-accent:       #1d4ed8;
    --td-accent-hover: #1e40af;
    --td-accent-soft:  #eff6ff;
    --td-success:      #059669;
    --td-success-soft:  #ecfdf5;
    --td-danger:       #e11d48;
    --td-danger-soft:  #fff1f2;
    --td-warning:      #d97706;
    --td-warning-soft: #fffbeb;
    --td-border:       #dde3ed;
    --td-fill:         #f7f9fc;
    --td-bg:           #d5d9e2;
    --td-card:         #ffffff;
    --td-font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --td-mono:         'JetBrains Mono', ui-monospace, monospace;

    font-family: var(--td-font);
    font-size: 14px;
    color: #111827;
    background: var(--td-bg);
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    align-items: stretch;
    margin: 0 0 40px;
}

/* ── Icons ── */
.gl-dash .gl-icon { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }

/* ── Sidebar ── */
.gl-dash__sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--td-ink);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    flex-shrink: 0;
}

.gl-dash__sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
}
.gl-dash__sidebar-brand {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gl-dash__sidebar-brand span {
    opacity: 0.5;
    font-weight: 400;
    font-size: 12px;
    margin-left: 4px;
}

.gl-dash__sidebar-nav {
    flex: 1;
    padding: 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.gl-dash__sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    padding: 10px 10px 4px;
    display: block;
}

.gl-dash__nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 10px;
    color: rgba(255,255,255,0.65);
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 500;
    transition: background-color .12s, color .12s;
}
.gl-dash__nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.gl-dash__nav-item--active { background: rgba(29,78,216,.35); color: #93c5fd; }

.gl-dash__sidebar-footer {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.gl-dash__sidebar-settings {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.55);
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 4px;
    transition: color .12s;
}
.gl-dash__sidebar-settings:hover { color: #fff; }
.gl-dash__sidebar-settings--active { color: #93c5fd; }
.gl-dash__sidebar-site-name {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.75);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.gl-dash__sidebar-footer-meta { display: flex; align-items: center; gap: 5px; }
.gl-dash__sidebar-user {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}
.gl-dash__sidebar-sep { font-size: 11px; color: rgba(255,255,255,0.2); }
.gl-dash__sidebar-version { font-size: 10px; color: rgba(255,255,255,0.25); font-family: var(--td-mono); }

/* ── Main content area ── */
.gl-dash__main {
    flex: 1;
    min-width: 0;
    background: var(--td-bg);
    overflow-y: auto;
}

/* ── Body ── */
.gl-dash__body {
    padding: 24px;
    min-height: 100vh;
}

/* ── Page header ── */
.gl-dash__page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.gl-dash__page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--td-ink);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.gl-dash__page-title .gl-icon { color: var(--td-accent); width: .9em; height: .9em; }

/* ── Notices ── */
.gl-dash__notice {
    margin-bottom: 20px;
}
.gl-notice { padding: 12px 16px; position: relative; }
.gl-notice::before { content: ''; position: absolute; top: 8px; left: 8px; width: 8px; height: 8px; border-radius: 50%; }
.gl-notice p { margin: 0; }
.gl-notice-success { background: var(--td-success-soft); color: var(--td-success); }
.gl-notice-success::before { background-color: var(--td-success); }
.gl-notice-info    { background: var(--td-accent-soft); color: var(--td-accent-hover); }
.gl-notice-info::before { background-color: var(--td-accent); }
.gl-notice-warning { background: var(--td-warning-soft); color: var(--td-warning); }
.gl-notice-warning::before { background-color: var(--td-warning); }
.gl-notice-error   { background: var(--td-danger-soft); color: var(--td-danger); }
.gl-notice-error::before { background-color: var(--td-danger); }

/* ── Stat cards — standard size matches CommercePilot's KPI cards ── */
.gl-dash__stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.gl-dash__stat-card {
    background: var(--td-card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 20px;
    text-align: center;
    position: relative;
}
.gl-dash__stat-card::before { content: ''; position: absolute; top: 8px; left: 8px; width: 8px; height: 8px; border-radius: 50%; background-color: var(--td-accent); }
.gl-dash__stat-card--warn::before { background-color: var(--td-warning); }
.gl-dash__stat-card--ok::before   { background-color: var(--td-success); }
.gl-dash__stat-num   { font-size: 36px; font-weight: 700; color: var(--td-ink); font-family: var(--td-mono); line-height: 1; }
.gl-dash__stat-label { color: #6B7280; margin: 8px 0 10px; font-size: 12px; }
.gl-dash__stat-link  { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--td-accent); text-decoration: none; }
.gl-dash__stat-link:hover { text-decoration: underline; }

/* ── Two-column layout ── */
.gl-dash__two-col {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 20px;
    align-items: start;
}

/* ── Cards ── */
.gl-dash__card {
    background: var(--td-card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    padding: 20px;
    margin-bottom: 16px;
}
.gl-dash__card:last-child { margin-bottom: 0; }
.gl-dash__card--flush { padding: 0; overflow: hidden; }
.gl-dash__card--danger { position: relative; }
.gl-dash__card--danger::before { content: ''; position: absolute; top: 8px; left: 8px; width: 8px; height: 8px; border-radius: 50%; background-color: var(--td-danger); }
.gl-dash__card--danger .gl-dash__card-header h2 { color: var(--td-danger); }

.gl-dash__card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.gl-dash__card-header h2 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--td-ink);
    display: flex;
    align-items: center;
    gap: 8px;
}
.gl-dash__card-header h2 .gl-icon { color: var(--td-accent); }
.gl-dash__card-action { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--td-accent); text-decoration: none; }
.gl-dash__card-action:hover { text-decoration: underline; }

/* ── Tables — row differentiation via zebra background, not borders ── */
.gl-dash__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.gl-dash__table thead th {
    background: var(--td-ink);
    color: #fff;
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.gl-dash__table tbody tr:nth-child(odd)  td { background: var(--td-fill); }
.gl-dash__table tbody tr:nth-child(even) td { background: #fff; }
.gl-dash__table tbody tr:hover td { background: var(--td-accent-soft); }
.gl-dash__table td { padding: 10px 14px; vertical-align: middle; }
.gl-dash__table .gl-dash__actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }

/* Detail table */
.gl-dash__detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.gl-dash__detail-table th {
    width: 160px;
    text-align: left;
    padding: 7px 10px;
    background: var(--td-fill);
    color: #555;
    font-weight: 600;
    font-size: 12px;
    vertical-align: top;
}
.gl-dash__detail-table tr:nth-child(even) td { background: var(--td-fill); }
.gl-dash__detail-table td { padding: 7px 10px; vertical-align: top; }

/* ── Badges (pills keep their shape — see CLAUDE.md scoping note) ── */
.gl-dash__badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
}
.gl-dash__badge--active  { background: var(--td-success-soft); color: var(--td-success); }
.gl-dash__badge--archived{ background: #eef0f2; color: #888; }
.gl-dash__badge--paid    { background: var(--td-success-soft); color: var(--td-success); }
.gl-dash__badge--unpaid  { background: var(--td-warning-soft); color: var(--td-warning); }
.gl-dash__badge--pending { background: var(--td-accent-soft); color: var(--td-accent-hover); }
.gl-dash__badge--waived  { background: #f1e9f7; color: #7b1fa2; }
.gl-dash__badge--full    { background: var(--td-danger-soft); color: var(--td-danger); }
.gl-dash__badge--ok      { background: var(--td-success-soft); color: var(--td-success); }
.gl-dash__badge--yes     { background: var(--td-success-soft); color: var(--td-success); }
.gl-dash__badge--no      { background: #eef0f2; color: #888; }

/* ── Links ── */
.gl-dash__link { color: var(--td-accent); text-decoration: none; }
.gl-dash__link:hover { text-decoration: underline; }
.gl-dash__link--strong { font-weight: 600; }
.gl-dash__link-back { display: inline-flex; align-items: center; gap: 4px; }

/* ── Meta / helper text ── */
.gl-dash__meta { font-size: 11px; color: #888; margin-left: 4px; }
.gl-dash__empty { color: #888; font-style: italic; padding: 16px; }
.gl-dash__result-count { color: #6B7280; font-size: 12px; margin: 8px 0 12px; }
.gl-dash__check { color: var(--td-success); font-weight: 600; }
.gl-dash__cross { color: var(--td-danger); }

/* ── Tab bar ── */
.gl-dash__tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.gl-dash__tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--td-ink);
    background: var(--td-fill);
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.gl-dash__tab:hover { background: var(--td-accent-soft); }
.gl-dash__tab.is-active { background: var(--td-ink); color: #fff; }
.gl-dash__tab-count { background: rgba(0,0,0,.12); border-radius: 999px; padding: 1px 7px; font-size: 11px; }
.gl-dash__tab.is-active .gl-dash__tab-count { background: rgba(255,255,255,.2); }

/* ── Filter bar ── */
.gl-dash__filter-bar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    padding: 14px;
    background: var(--td-card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 16px;
}
.gl-dash__filter-bar .gl-dash__input,
.gl-dash__filter-bar .gl-dash__select {
    width: auto;
    flex: 1 1 160px;
}
.gl-dash__search { min-width: 200px; flex: 2 1 220px; }
.gl-dash__filter-sep { color: #aaa; }
.gl-dash__filter-bar .gl-btn { flex: 0 0 auto; }

/* ── Pagination ── */
.gl-dash__pagination { display: flex; gap: 4px; flex-wrap: wrap; padding: 12px 14px; margin-top: 4px; }

/* ── Buttons — differentiated by fill colour, not border ── */
.gl-dash .gl-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: background .15s, color .15s; font-family: var(--td-font); line-height: 1; text-decoration: none; white-space: nowrap; }
.gl-dash .gl-btn-primary   { background: var(--td-accent); color: #fff; }
.gl-dash .gl-btn-primary:hover { background: var(--td-accent-hover); color: #fff; }
.gl-dash .gl-btn-secondary { background: var(--td-fill); color: var(--td-ink); }
.gl-dash .gl-btn-secondary:hover { background: var(--td-accent-soft); color: var(--td-accent-hover); }
.gl-dash .gl-btn-warn      { background: var(--td-warning-soft); color: var(--td-warning); }
.gl-dash .gl-btn-warn:hover{ background: var(--td-warning); color: #fff; }
.gl-dash .gl-btn-danger    { background: var(--td-danger-soft); color: var(--td-danger); }
.gl-dash .gl-btn-danger:hover { background: var(--td-danger); color: #fff; }
.gl-dash .gl-btn-sm        { padding: 5px 12px; font-size: 12px; }
.gl-dash .gl-btn-large     { padding: 12px 28px; font-size: 15px; }
.gl-dash .gl-btn--block    { width: 100%; display: flex; }

/* ── Forms ── */
.gl-dash__form-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}
.gl-dash__field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.gl-dash__field:last-child { margin-bottom: 0; }
.gl-dash__field--full { grid-column: 1 / -1; }
.gl-dash__field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.gl-dash__field label { font-size: 13px; font-weight: 600; color: #333; }
.gl-dash__field-note { font-size: 11px; color: #888; margin: 2px 0 0; }

.gl-dash__input,
.gl-dash__textarea,
.gl-dash__select {
    padding: 9px 12px;
    font-size: 13px;
    font-family: var(--td-font);
    width: 100%;
    box-sizing: border-box;
    transition: background-color .15s, box-shadow .15s;
    background: var(--td-fill);
    border: none;
    border-radius: 0;
}
.gl-dash__input:focus,
.gl-dash__textarea:focus,
.gl-dash__select:focus {
    outline: none;
    background: var(--td-accent-soft);
    box-shadow: 0 0 0 3px rgba(29,78,216,.15);
}
.gl-dash__textarea { resize: vertical; }
.gl-dash__textarea--code { font-family: 'Courier New', monospace; font-size: 12px; }
.gl-dash__select--full { width: 100%; }

/* Native <select>/<input type=date> chrome paints its own rounded skin
   regardless of border-radius:0 unless the OS widget theme is disabled. */
.gl-dash__select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2364748b' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 10px 6px;
    cursor: pointer;
}
.gl-dash__input[type="date"] {
    appearance: none;
    -webkit-appearance: none;
}

/* Checkbox / radio */
.gl-dash__checkbox-label { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.gl-dash__checkbox-label input { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; accent-color: var(--td-accent); }
.gl-dash__radio-group { display: flex; flex-direction: column; gap: 16px; }
.gl-dash__radio-label { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 12px 14px; background: var(--td-fill); transition: background .15s; }
.gl-dash__radio-label:has(input:checked) { background: var(--td-accent-soft); }
.gl-dash__radio-label input { margin-top: 3px; flex-shrink: 0; accent-color: var(--td-accent); }

/* Colour picker */
.gl-dash__colour-row { display: flex; align-items: center; gap: 10px; }
.gl-dash__colour-row input[type="color"] { width: 48px; height: 36px; border: none; padding: 2px; cursor: pointer; background: var(--td-fill); }

/* Meta row */
.gl-dash__meta-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 10px; font-size: 13px; }
.gl-dash__meta-row:nth-child(even) { background: var(--td-fill); }

/* Quick actions */
.gl-dash__quick-actions { display: flex; flex-direction: column; gap: 8px; }

/* Logo preview */
.gl-dash__logo-preview { max-height: 60px; margin-top: 8px; padding: 4px; background: var(--td-fill); display: block; }

/* Form actions footer */
.gl-dash__form-actions { margin-top: 24px; padding-top: 20px; }

/* Activity log */
.gl-dash__log { list-style: none; padding: 0; margin: 0; }
.gl-dash__log li { padding: 8px 10px; font-size: 12px; }
.gl-dash__log li:nth-child(even) { background: var(--td-fill); }

/* Detail layout */
.gl-dash__detail-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 20px;
    align-items: start;
}

/* Required asterisk */
.gl-required { color: var(--td-danger); }

/* ── Responsive ── */
@media (max-width: 900px) {
    .gl-dash__stats        { grid-template-columns: 1fr 1fr; }
    .gl-dash__two-col      { grid-template-columns: 1fr; }
    .gl-dash__detail-grid  { grid-template-columns: 1fr; }
    .gl-dash__form-grid    { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .gl-dash { flex-direction: column; }
    .gl-dash__sidebar {
        width: 100%;
        min-width: 0;
        height: auto;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px;
    }
    .gl-dash__sidebar-logo { padding: 8px 10px; }
    .gl-dash__sidebar-nav  { flex-direction: row; flex-wrap: wrap; padding: 0 6px 8px; gap: 4px; flex: none; width: 100%; }
    .gl-dash__sidebar-section-label { display: none; }
    .gl-dash__sidebar-footer { display: none; }
    .gl-dash__body { padding: 14px; }
}
@media (max-width: 680px) {
    .gl-dash__stats        { grid-template-columns: 1fr 1fr; }
    .gl-dash__filter-bar   { flex-direction: column; align-items: stretch; }
    .gl-dash__search       { min-width: unset; }
    .gl-dash__filter-bar .gl-dash__input,
    .gl-dash__filter-bar .gl-dash__select,
    .gl-dash__filter-bar .gl-btn { flex: none; width: 100%; }
    .gl-dash__field-row    { grid-template-columns: 1fr; }
    .gl-dash__table        { font-size: 12px; }
    .gl-dash__table thead th,
    .gl-dash__table td     { padding: 8px 10px; }
}
@media (max-width: 480px) {
    .gl-dash__stats { grid-template-columns: 1fr; }
}
