/* Fivestar OS */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap');

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: #0f1115;
    color: #e6e8ee;
    font-size: 13px;
}

/* Form controls don't inherit font-family by default. */
button, input, select, textarea {
    font-family: inherit;
}

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    background: #161922;
    border-bottom: 1px solid #232838;
    position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo-img { height: 22px; width: auto; display: block; }
.brand .logo { color: #ffb648; font-size: 22px; }
.brand .name { font-weight: 700; font-size: 18px; letter-spacing: .3px; }
.brand .tag  { color: #8a93a8; font-size: 12px; }
.actions { display: flex; gap: 8px; }

/* --- Sidebar layout ----------------------------------------------------- */
body.has-sidebar { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    flex: 0 0 220px;
    background: #11141c;
    border-right: 1px solid #232838;
    display: flex; flex-direction: column;
    position: sticky; top: 0;
    height: 100vh;
    z-index: 15;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 21px 20px 21px;
    min-height: 63px;
    border-bottom: 1px solid #1c2030;
}
.sidebar-brand .logo-img { height: 20px; width: auto; display: block; }
.sidebar-brand .tag { color: #8a93a8; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }

.sidebar-nav {
    display: flex; flex-direction: column;
    padding: 12px 10px;
    gap: 2px;
    flex: 1;
}
.sidebar-foot {
    padding: 10px;
    border-top: 1px solid #1c2030;
}
.sidebar-link {
    display: block;
    padding: 9px 14px;
    border-radius: 6px;
    color: #c9d3e6;
    text-decoration: none;
    font-size: 13px; font-weight: 500;
    transition: background .12s, color .12s;
}
.sidebar-link:hover { background: #1a1e2a; color: #ffffff; }
.sidebar-link.active {
    background: #232838;
    color: #ffb648;
}
.sidebar-link.logout { color: #8a93a8; }
.sidebar-link.logout:hover { color: #ffb6b6; background: #2a1a1f; }

.app-main {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    gap: 18px;
    padding-bottom: 32px;
}

/* Topbar inside the app-main column (sidebar layout) */
body.has-sidebar .topbar {
    padding: 14px 24px;
    min-height: 63px;
}
.topbar .page-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #e6e8ee;
    letter-spacing: .2px;
}

.btn {
    background: #2d3243; color: #e6e8ee;
    border: 1px solid #3a4159; border-radius: 6px;
    padding: 7px 14px; cursor: pointer; font-size: 13px; font-weight: 500;
    transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: #3a4159; border-color: #4a5170; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn:disabled { opacity: .4; cursor: not-allowed; }
.btn[disabled]:hover, .btn:disabled:hover { background: #2d3243; border-color: #3a4159; }
.btn.primary { background: #ffb648; color: #1a1300; border-color: #ffb648; font-weight: 600; }
.btn.primary:hover { background: #ffc977; border-color: #ffc977; }
.btn.ghost { background: transparent; border-color: transparent; color: #8a93a8; font-size: 22px; line-height: 1; padding: 4px 10px; }
.btn.ghost:hover { background: #2d3243; color: #e6e8ee; }
.btn.danger { background: #4a1f23; border-color: #6a2a30; color: #ffb6b6; }
.btn.danger:hover { background: #5a262b; border-color: #7a3038; }

.stats {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 12px; padding: 0 24px;
}
.stat {
    background: #161922; border: 1px solid #232838; border-radius: 8px;
    padding: 12px 16px; display: flex; flex-direction: column; gap: 4px;
}
.stat .label { color: #8a93a8; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.stat .value { font-size: 20px; font-weight: 600; }

.filters {
    display: flex; gap: 8px; padding: 0 24px; align-items: center;
    flex-wrap: wrap;
}
.filters input, .filters select {
    background: #161922; border: 1px solid #232838; color: #e6e8ee;
    border-radius: 6px; padding: 7px 10px; font-size: 13px;
    min-width: 0;
}
.filters input { flex: 1 1 220px; min-width: 160px; }
.filters select { flex: 0 1 auto; max-width: 100%; }
.filters .btn { flex: 0 0 auto; }
.filters input:focus, .filters select:focus { outline: none; border-color: #ffb648; }

main { padding: 0 24px; }

/* Horizontal scroll container so the wide orders table never forces the
   whole page to overflow on narrow viewports. */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
}

table.orders {
    width: 100%; border-collapse: collapse;
    background: #161922; border: 1px solid #232838; border-radius: 8px; overflow: hidden;
}
table.orders th, table.orders td {
    padding: 10px 14px; text-align: left; border-bottom: 1px solid #232838;
}
table.orders th {
    background: #1a1e2a; color: #8a93a8;
    font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
    font-weight: 600;
    white-space: nowrap;
}
table.orders tbody tr { cursor: pointer; transition: background .1s; }
table.orders tbody tr:hover { background: #1c2030; }
/* Workflow status indicator: 5px bar shown only on "open" rows so they
   stand out at a glance. Uses an inset box-shadow on the first cell so
   rows without an indicator aren't indented and layout stays consistent. */
table#orders tbody tr[data-istatus="open"] > td:first-child {
    box-shadow: inset 3px 0 0 0 #ef5a5a;
}
table#orders th:first-child,
table#orders td:first-child {
    padding-left: 25px;
}
table.orders td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.orders th.num { text-align: right; }
table.orders .empty { text-align: center; color: #8a93a8; padding: 30px; }

.badge {
    display: inline-block; padding: 2px 8px; border-radius: 99px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
}
.badge.src-stripe { background: #1f3a5a; color: #8ec7ff; }
.badge.src-manual { background: #3a2f1f; color: #ffd28e; }
.badge.src-direct { background: #1f3a2a; color: #8eea9a; }
.badge.status-new        { background: #2a3148; color: #aab8f0; }
.badge.status-processing { background: #3a3010; color: #ffd28e; }
.badge.status-shipped    { background: #1a3a3a; color: #8eebd6; }
.badge.status-completed  { background: #1f4a2a; color: #8eea9a; }
.badge.status-cancelled  { background: #4a1f23; color: #ffb6b6; }
.badge.status-refunded   { background: #2a2a2a; color: #c0c0c0; }

.badge.istatus-open      { background: #2a3148; color: #aab8f0; }
.badge.istatus-progress  { background: #3a3010; color: #ffd28e; }
.badge.istatus-finished  { background: #1f4a2a; color: #8eea9a; }
.badge.istatus-cancelled { background: #4a1f23; color: #ffb6b6; }

.badge.reminder-first    { background: #3a3010; color: #ffd28e; }
.badge.reminder-second   { background: #4a1f23; color: #ffb6b6; }
.badge.reminder-none     { background: #232a3a; color: #6f86b3; }
.reminder-na             { color: #4a5568; font-size: 11px; }

.badge.platform          { background: #1f2532; color: #c9d3e6; text-transform: none; letter-spacing: 0; font-weight: 500; }
.badge.platform-unknown  { background: #1a2436; color: #6f86b3; }

/* --- Log levels ------------------------------------------------------------ */
.badge.log-info    { background: #1f3050; color: #9ec1ff; }
.badge.log-warn    { background: #3a3010; color: #ffd28e; }
.badge.log-error   { background: #4a1a1a; color: #ff9a9a; }
.badge.log-cat     { background: #1f2532; color: #c9d3e6; text-transform: none; letter-spacing: 0; font-weight: 500; }

td.mono            { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; color: #b6c0d6; }
td.ctx             { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.ctx:hover       { white-space: normal; word-break: break-all; }

.pager             { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 18px 0; color: #8a93a8; }
.pager .btn        { min-width: 96px; }
.pager .btn[disabled] { opacity: .4; cursor: not-allowed; }
.pager #page-info  { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; min-width: 90px; text-align: center; }

/* Drawer */
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 95vw;
    background: #0f1115; border-left: 1px solid #232838;
    box-shadow: -8px 0 30px rgba(0,0,0,.5);
    display: flex; flex-direction: column;
    z-index: 20;
    transition: transform .2s ease;
}
.drawer.hidden { transform: translateX(100%); pointer-events: none; box-shadow: none; }
.drawer-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid #232838;
}
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { padding: 18px; overflow: auto; flex: 1; }

.drawer-body .field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.drawer-body label { color: #8a93a8; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.drawer-body input, .drawer-body select, .drawer-body textarea {
    background: #212430; border: 1px solid #2d3243; color: #e6e8ee;
    border-radius: 6px; padding: 8px 10px; font-size: 13px; font-family: inherit;
    transition: border-color .12s ease, background .12s ease;
}
.drawer-body input:hover:not(:disabled):not([readonly]):not(:focus),
.drawer-body select:hover:not(:disabled):not(:focus),
.drawer-body textarea:hover:not(:disabled):not([readonly]):not(:focus) {
    border-color: #3a4159;
}
.drawer-body input:focus,
.drawer-body select:focus,
.drawer-body textarea:focus,
.drawer-body input:active:not(:disabled):not([readonly]),
.drawer-body select:active:not(:disabled),
.drawer-body textarea:active:not(:disabled):not([readonly]) {
    outline: none; border-color: #ffb648; background: #262a38;
}
.drawer-body input:disabled,
.drawer-body select:disabled,
.drawer-body textarea:disabled,
.drawer-body input[readonly],
.drawer-body textarea[readonly],
.drawer-body input.readonly {
    background: transparent;
    border-style: dashed;
    border-color: #2a3040;
    color: #8a93a8;
    cursor: not-allowed;
}
.drawer-body textarea { min-height: 70px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* --- Settings: info panels & locked secrets ------------------------------ */
.info-panel {
    background: #11141c; border: 1px solid #232838; border-radius: 8px;
    padding: 10px 12px; margin-bottom: 10px;
}
.info-panel.muted { background: #11141c; border-style: dashed; color: #8a93a8; }
.info-grid {
    display: grid; grid-template-columns: max-content 1fr;
    gap: 6px 14px; align-items: center;
}
.info-grid .k { color: #8a93a8; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.info-grid .v { font-size: 12px; color: #e6e8ee; word-break: break-all; }
.info-grid .v code { background: #1a1e2a; padding: 2px 6px; border-radius: 4px; font-size: 11px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: #1a1e2a; border: 1px solid #232838; border-radius: 99px;
    padding: 3px 10px; font-size: 11px; color: #c9d3e6;
}
.chip .chip-k { color: #8a93a8; text-transform: uppercase; letter-spacing: .5px; font-size: 10px; }
.chip .chip-v { font-variant-numeric: tabular-nums; font-weight: 600; }
.chip.ok    { border-color: #1f4a2a; color: #8eea9a; }
.chip.warn  { border-color: #3a3010; color: #ffd28e; }
.chip.error { border-color: #4a1a1a; color: #ff9a9a; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #444; margin-right: 6px; vertical-align: middle; }
.dot.ok    { background: #6bcf7f; }
.dot.warn  { background: #ffb648; }
.dot.error { background: #ff7b7b; }

/* Locked secret input: input + Edit button row */
.lock-field { display: flex; gap: 8px; align-items: stretch; }
.lock-field input { flex: 1; }
.lock-field input:disabled {
    background: #14171f; color: #6f7892; border-style: dashed; cursor: not-allowed;
}
.lock-field .lock-btn { white-space: nowrap; }
.lock-hint {
    font-size: 11px; color: #8a93a8; margin-top: 4px;
    display: flex; align-items: center; gap: 6px;
}
.lock-hint code { background: #1a1e2a; padding: 1px 6px; border-radius: 4px; }

.meta-list { display: flex; flex-direction: column; gap: 6px; }
.meta-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; }
.meta-row input { width: 100%; }

.events {
    max-height: 280px;
    overflow: auto;
    display: flex; flex-direction: column;
    margin-bottom: 12px;
}
.events h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; color: #8a93a8; letter-spacing: .6px; }
.events .empty { color: #6f7689; font-size: 12px; padding: 12px 0; text-align: center; }

.event {
    display: grid;
    grid-template-columns: 8px 1fr;
    column-gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #232838;
    font-size: 12.5px;
    position: relative;
}
.event:last-child { border-bottom: none; }
.event::before {
    content: "";
    width: 7px; height: 7px;
    background: #ffb648;
    border-radius: 50%;
    margin-top: 6px;
    grid-column: 1;
    align-self: start;
}
.event .event-body { grid-column: 2; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.event .event-head {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}
.event .type {
    color: #ffb648;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    background: rgba(255,182,72,.08);
    border: 1px solid rgba(255,182,72,.22);
    padding: 2px 7px;
    border-radius: 4px;
}
.event .t {
    color: #6f7689;
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}
.event .msg {
    color: #c9ccd6;
    line-height: 1.45;
    word-wrap: break-word;
}

.drawer-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding-top: 14px; border-top: 1px solid #232838; margin-top: 14px;
}
.drawer-actions .spacer { flex: 1; }

.notify-row { display: flex; align-items: center; gap: 6px; color: #8a93a8; font-size: 12px; }

/* Drawer tabs */
.drawer-tabs {
    display: flex; gap: 0;
    border-bottom: 1px solid #232838;
    margin: -18px -18px 16px;
    padding: 0 18px;
}
.drawer-tab {
    background: transparent; border: none; color: #8a93a8;
    padding: 10px 14px; cursor: pointer;
    font-family: inherit; font-size: 12px;
    text-transform: uppercase; letter-spacing: .6px; font-weight: 600;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.drawer-tab:hover { color: #e6e8ee; }
.drawer-tab.active { color: #ffb648; border-bottom-color: #ffb648; }
.drawer-tab.disabled,
.drawer-tab[disabled] {
    color: #4a5066; cursor: not-allowed; opacity: .6;
}
.drawer-tab.disabled:hover,
.drawer-tab[disabled]:hover { color: #4a5066; }

/* Clickbits campaign cards */
.cb-card {
    background: #161922; border: 1px solid #232838; border-radius: 10px;
    padding: 18px 18px 16px; margin-bottom: 14px;
}
.cb-card-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 10px;
}
.cb-title { font-size: 15px; font-weight: 600; color: #e6e8ee; line-height: 1.3; }
.cb-subtitle {
    color: #8a93a8; font-size: 11px; text-transform: uppercase;
    letter-spacing: .6px; margin-top: 4px;
}

.cb-badge {
    flex: 0 0 auto;
    display: inline-block; padding: 3px 9px; border-radius: 99px;
    font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
    background: #232838; color: #c9d3e6;
}
.cb-status-active   { background: #1f4a2a; color: #8eea9a; }
.cb-status-inactive { background: #4a1f23; color: #ffb6b6; }
.cb-status-paused   { background: #3a3010; color: #ffd28e; }
.cb-status-draft    { background: #2a3148; color: #aab8f0; }

.cb-dates {
    display: flex; flex-direction: column; gap: 3px;
    color: #c9d3e6; font-size: 12px;
    margin-top: 12px; padding-top: 10px;
    border-top: 1px dashed #232838;
}
.cb-k-inline {
    display: inline-block; min-width: 78px;
    color: #8a93a8; text-transform: uppercase; letter-spacing: .6px;
    font-size: 10px; font-weight: 600;
}

.cb-progress { margin-top: 16px; }
.cb-progress-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 6px;
}
.cb-progress-label {
    color: #8a93a8; font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
}
.cb-progress-value {
    color: #e6e8ee; font-size: 12px; font-variant-numeric: tabular-nums;
}
.cb-progress-bar {
    height: 6px; background: #232838; border-radius: 999px; overflow: hidden;
}
.cb-progress-fill {
    height: 100%; background: #ffb648;
    transition: width .3s ease;
}

.cb-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    margin-top: 16px;
}
.cb-stat {
    display: flex; flex-direction: column; gap: 2px;
    background: #0f1115; border: 1px solid #232838; border-radius: 8px;
    padding: 10px 12px;
}
.cb-stat-v {
    color: #ffb648; font-size: 15px; font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.cb-stat-k {
    color: #8a93a8; font-size: 10px;
    text-transform: uppercase; letter-spacing: .6px;
}

.cb-desc { margin-top: 16px !important; margin-bottom: 4px !important; }
.cb-desc textarea {
    font-size: 11.5px !important;
    line-height: 1.5 !important;
    color: #c9d3e6 !important;
}

.cb-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
    margin-top: 4px;
}
.cb-kv { display: flex; flex-direction: column; gap: 2px; }
.cb-k { color: #8a93a8; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; }
.cb-v { color: #e6e8ee; font-size: 12.5px; word-break: break-word; }

.cb-section-title {
    margin: 18px 0 8px;
    color: #8a93a8; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 600;
}
.cb-tasks {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 16px;
}
.cb-task {
    display: flex; justify-content: space-between;
    font-size: 12px; padding: 4px 0;
    border-bottom: 1px dashed #232838;
}
.cb-task-k { color: #8a93a8; text-transform: capitalize; }
.cb-task-v { color: #e6e8ee; font-variant-numeric: tabular-nums; font-weight: 600; }

.cb-foot {
    margin-top: 16px; padding-top: 12px;
    border-top: 1px dashed #232838;
    display: flex; flex-direction: column; gap: 6px;
}
.cb-link {
    color: #ffb648; text-decoration: none; font-size: 12px;
}
.cb-link:hover { text-decoration: underline; }

.cb-empty {
    color: #8a93a8; font-size: 12px;
    background: #161922; border: 1px dashed #232838; border-radius: 6px;
    padding: 14px; text-align: center; margin: 0;
}

.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: #161922; color: #e6e8ee; border: 1px solid #2e3447;
    padding: 10px 18px; border-radius: 6px;
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
    z-index: 30; font-size: 13px;
}
.toast.hidden { display: none; }
.toast.error  { border-color: #6a2a30; color: #ffb6b6; }
.toast.success{ border-color: #2a6a3c; color: #8eea9a; }

@media (max-width: 720px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .drawer { width: 100%; }
    body.has-sidebar { flex-direction: column; }
    body.has-sidebar .topbar { border-top: 1px solid #232838; }    
    .sidebar {
        width: 100%; flex: 0 0 auto;
        height: auto; position: static;
        flex-direction: row; align-items: center;
        overflow-x: auto;
    }
    .sidebar-brand { border-bottom: none; border-right: 1px solid #1c2030; padding: 10px 14px; }
    .sidebar-nav { flex-direction: row; padding: 8px; flex: 1; }
    .sidebar-foot { border-top: none; border-left: 1px solid #1c2030; padding: 8px; }
    .sidebar-link { white-space: nowrap; padding: 7px 10px; }
}

/* --- Responsive orders table / filters ---------------------------------- */

/* Filters: at narrower widths, let inputs/selects each grow to fill a row
   so they don't overflow the viewport horizontally. */
@media (max-width: 960px) {
    .filters input { flex: 1 1 100%; }
    .filters select { flex: 1 1 calc(50% - 4px); }
}
@media (max-width: 560px) {
    .filters select, .filters .btn { flex: 1 1 100%; }
}

/* Page padding / table chrome shrink at smaller widths. */
@media (max-width: 960px) {
    table.orders th, table.orders td { padding: 9px 10px; }
    .sidebar-brand { padding: 19px 20px 19px;}    
}

/* Progressive column hiding for the orders table.
   Columns: 1#  2 Source  3 Customer  4 Description  5 Platform
            6 Amount  7 Status  8 Payment  9 Created
*/
@media (max-width: 1100px) {
    table.orders th:nth-child(4), table.orders td:nth-child(4), /* Description */
    table.orders th:nth-child(9), table.orders td:nth-child(9)  /* Created */
    { display: none; }
}
@media (max-width: 900px) {
    table.orders th:nth-child(5), table.orders td:nth-child(5)  /* Platform */
    { display: none; }
}
@media (max-width: 720px) {
    table.orders th:nth-child(8), table.orders td:nth-child(8)  /* Payment */
    { display: none; }
}
@media (max-width: 520px) {
    table.orders th:nth-child(2), table.orders td:nth-child(2)  /* Source */
    { display: none; }
    table.orders th, table.orders td { padding: 8px 8px; font-size: 12px; }
}

/* Settings page wraps the form in a comfortable max-width container. */
main.settings-page {
    padding: 0 24px;
}
.settings-body {
    max-width: 760px;
    background: transparent;
    padding: 0;
    overflow: visible;
}

/* Login */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
}
.login-card {
    width: 360px; max-width: 92vw;
    background: #161922; border: 1px solid #232838; border-radius: 10px;
    padding: 26px 24px;
    box-shadow: 0 10px 40px rgba(0,0,0,.5);
}
.login-card .field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.login-card label { color: #8a93a8; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
.login-card input {
    background: #0f1115; border: 1px solid #232838; color: #e6e8ee;
    border-radius: 6px; padding: 9px 11px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: #ffb648; }
a.btn { display: inline-block; text-decoration: none; }

.fos-copy { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.fos-copy:hover { color: #ffb648; }

/* ---------- Drawer cards (grouped sections) ---------- */
.section-title {
    margin: 18px 0 10px;
    font-size: 12px; color: #8a93a8;
    text-transform: uppercase; letter-spacing: .8px; font-weight: 600;
}
.fos-card {
    background: #161922;
    border: 1px solid #232838;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.fos-card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px;
    margin: 0 0 12px;
}
.fos-card-head h3 {
    margin: 0;
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .8px;
    color: #c8cdd9;
}
.fos-card-meta {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; color: #8a93a8;
}
.fos-card-ext {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px; color: #8a93a8;
    background: #0f1115; border: 1px solid #232838; border-radius: 4px;
    padding: 1px 6px;
}
.fos-card-body > .field:last-child,
.fos-card-body > .row-2:last-child,
.fos-card-body > .row-3:last-child,
.fos-card-body > .row-1-2:last-child { margin-bottom: 0; }

.fos-card.empty-card { border-style: dashed; }
.fos-card .invoice-actions {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.invoice-num {
    color: #ffb648; font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

/* Collapsibles (Hinweise, Custom metadata) */
.fos-collapse > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.fos-collapse > summary::-webkit-details-marker { display: none; }
.fos-collapse > summary.as-summary {
    /* used inside a card as the head row */
    cursor: pointer;
}
.fos-collapse > summary::after {
    content: "▸";
    margin-left: auto;
    color: #8a93a8;
    font-size: 11px;
    transition: transform .15s ease;
}
.fos-collapse[open] > summary::after { transform: rotate(90deg); }

/* Inline hints */
.hint {
    color: #8a93a8;
    font-size: 11px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

/* Read-only Amount when items drive the total: handled by generic
   [readonly]/.readonly rule above. */

/* Activity / note row */
.note-add-row {
    display: flex; gap: 6px; margin-top: 10px;
}
.note-add-row input { flex: 1; }

/* Small action buttons in card heads */
.btn.small { padding: 4px 10px; font-size: 11px; }

/* Inline action row (button + result text) */
.inline-actions {
    flex-direction: row !important;
    align-items: center;
    gap: 8px;
}
.inline-actions.wrap { flex-wrap: wrap; }
.action-result {
    font-size: 12px;
    color: #8a93a8;
}

/* ---------- Billing / Invoice editor ---------- */
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.row-1-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }

.vat-status {
    font-size: 11px; margin-top: 4px;
    display: flex; align-items: center; gap: 6px;
}
.vat-status.ok    { color: #8eea9a; }
.vat-status.bad   { color: #ffb6b6; }
.vat-status.muted { color: #8a93a8; }

.li-list {
    display: flex; flex-direction: column;
    gap: 10px;
}

/* ----- Line item row -----
   Description occupies its own line on top.
   Qty / Unit price / Total / Remove sit on a second line beneath. */
.li-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: #1a1e28;
    border: 1px solid #252837;
    border-top: 3px solid #35dc8d;
}

/* Labels */
.li-row .li-field-lbl {
    display: block;
    color: #6f7689;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .7px;
    font-weight: 600;
    margin-bottom: 4px;
}

/* Description — full width on its own line */
.li-row .li-desc-wrap { display: block; min-width: 0; }

/* Numerics row: qty | unit price | discount % | total | remove */
.li-row .li-meta {
    display: grid;
    grid-template-columns: 60px 80px 80px 1fr 34px;
    column-gap: 10px;
    align-items: end;
}
.li-row .li-field,
.li-row .li-total-wrap {
    display: block;
    min-width: 0;
}
.li-row .li-total-wrap { text-align: right; }

/* Inputs */
.li-row input {
    background: #11141c;
    border: 1px solid #2d3243;
    color: #e6e8ee;
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    width: 100%;
    height: 34px;
    box-sizing: border-box;
    font-family: inherit;
}
.li-row input::placeholder { color: #5a6275; }
.li-row input:focus { outline: none; border-color: #ffb648; }

.li-row .li-desc { font-size: 13.5px; }
.li-row .li-field input { font-variant-numeric: tabular-nums; }

/* Total — read-only value, aligned right */
.li-row .li-total-val {
    color: #ffb648;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    height: 34px;
    display: flex; align-items: center; justify-content: flex-end;
}

/* Remove button */
.li-row .btn.ghost {
    height: 34px;
    width: 34px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
    color: #6f7689;
    background: transparent;
    border: 1px solid #2d3243;
    border-radius: 6px;
    align-self: end;
}
.li-row .btn.ghost:hover {
    color: #ffffff;
    background: #ff194f;
    border-color: #ff194f;
}

.li-empty {
    color: #6f7689; font-size: 12.5px;
    padding: 20px; text-align: center;
    background: transparent;
    border: 1px dashed #2a3040;
    border-radius: 8px;
}

/* Receipt-style totals (no surrounding box) */
.li-totals {
    margin-top: 14px;
    padding: 0 4px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 18px;
    font-size: 12.5px;
}
.li-totals .lbl { color: #8a93a8; }
.li-totals .val { text-align: right; font-variant-numeric: tabular-nums; color: #c9ccd6; }
.li-totals .grand { display: contents; }
.li-totals .grand .lbl,
.li-totals .grand .val {
    border-top: 1px solid #2d3243;
    padding-top: 8px;
    margin-top: 4px;
}
.li-totals .grand .lbl { color: #e6e8ee; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; font-size: 11px; }
.li-totals .grand .val { color: #ffb648; font-weight: 700; font-size: 15px; }


/* ---------- Custom scrollbars: always visible, no arrows ---------- */
/* Firefox */
html {
    scrollbar-color: #232838 transparent;
}

/* WebKit / Chromium */
::-webkit-scrollbar {
    width: 5%;
    height: 5px;
    background: transparent;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: #232838;
    border-radius: 999px;
    min-height: 30px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.38); }
::-webkit-scrollbar-thumb:active { background: rgba(255,255,255,0.55); }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-button { display: none; }




/* =========================================================================
   Analytics dashboard
   ========================================================================= */
.analytics-range {
    flex-wrap: wrap;
    gap: 10px 12px;
}
.analytics-range .range-presets {
    display: flex; gap: 6px; flex-wrap: wrap;
}
.analytics-range .range-presets .btn.preset {
    padding: 6px 10px;
    font-size: 12px;
}
.analytics-range .range-label {
    display: inline-flex; align-items: center; gap: 6px;
    color: #8a93a8;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
}
.analytics-range .range-label input,
.analytics-range .range-label select {
    background: #161922; border: 1px solid #232838; color: #e6e8ee;
    border-radius: 6px; padding: 6px 8px; font-size: 12px;
    color-scheme: dark;
}
.analytics-range .range-label input:focus,
.analytics-range .range-label select:focus { outline: none; border-color: #ffb648; }

/* KPI cards — extend the standard .stat with a delta line. */
.analytics-kpis {
    grid-template-columns: repeat(6, 1fr);
}
@media (max-width: 1200px) {
    .analytics-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 700px) {
    .analytics-kpis { grid-template-columns: repeat(2, 1fr); }
}
.stat.kpi .delta {
    font-size: 11px;
    color: #8a93a8;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
}
.stat.kpi .delta.up    { color: #8eea9a; }
.stat.kpi .delta.down  { color: #ff9a9a; }
.stat.kpi .delta.muted { color: #8a93a8; }

/* Card grid for charts. */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    padding: 0 24px;
}
.analytics-grid .card.card-wide { grid-column: span 2; }
@media (max-width: 900px) {
    .analytics-grid { grid-template-columns: 1fr; }
    .analytics-grid .card.card-wide { grid-column: span 1; }
}

/* Three-up variant for the doughnut row. */
.analytics-grid.analytics-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 900px) {
    .analytics-grid.analytics-grid-3 { grid-template-columns: 1fr; }
}

.analytics-grid .card {
    background: #161922;
    border: 1px solid #232838;
    border-radius: 8px;
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.analytics-grid .card-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px;
}
.analytics-grid .card-head h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
    color: #e6e8ee;
}
.analytics-grid .card-sub {
    font-size: 11px;
    color: #8a93a8;
    text-transform: uppercase;
    letter-spacing: .6px;
}
.analytics-grid .card-body { min-width: 0; overflow-x: auto; }

.chart-wrap {
    position: relative;
    width: 100%;
    height: 260px;
}
.chart-wrap.chart-tall { height: 340px; }

/* Compact table inside cards (top customers / currencies). */
table.orders.compact th,
table.orders.compact td {
    padding: 8px 10px;
    font-size: 12px;
}
table.orders.compact tbody tr { cursor: default; }
table.orders.compact tbody tr:hover { background: transparent; }

/* Toast inside analytics page (in case style.css doesn't already cover it). */


/* --- Settings: payment providers --------------------------------------- */
.settings-group { margin-bottom: 22px; }
.settings-group-title {
    margin: 4px 0 4px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .8px; color: #8a93a8;
}
.settings-group-hint { margin: 0 0 10px; font-size: 12px; }

.provider-card { border-left: 3px solid #2b6cb0; }
.provider-card[data-provider-card] .fos-card-head .fos-card-meta { flex-wrap: wrap; }

.provider-subsection {
    margin-top: 14px; padding-top: 12px;
    border-top: 1px dashed #232838;
}
.provider-sub-title {
    margin: 0 0 10px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .8px; color: #8a93a8;
}

.toggle-inline {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 11px; color: #c8cdd9; cursor: pointer;
    user-select: none;
}
.toggle-inline input[type="checkbox"] { margin: 0; cursor: pointer; }

/* --- Custom checkbox toggle -------------------------------------------- */
.ctl-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    cursor: pointer; user-select: none;
    font-size: 13px;
}
.ctl-toggle input {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; border: 0;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap;
}
.ctl-toggle-box {
    position: relative;
    width: 1.5em;
    height: 1.5em;
    border-radius: 3px;
    background: #2d3243;
    flex-shrink: 0;
    transition: background 0.15s;
}
.ctl-toggle-box::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 45%;
    width: 0.34em;
    height: 0.62em;
    border-right: 2px solid #1a1300;
    border-bottom: 2px solid #1a1300;
    transform: translate(-50%, -50%) rotate(45deg) scale(0);
    opacity: 0;
    transition: transform 0.18s cubic-bezier(0.4, 1.5, 0.5, 1), opacity 0.12s;
}
.ctl-toggle input:checked ~ .ctl-toggle-box {
    background: #ffb648;
}
.ctl-toggle input:checked ~ .ctl-toggle-box::after {
    transform: translate(-50%, -50%) rotate(45deg) scale(0.9);
    opacity: 1;
}
.ctl-toggle input:focus-visible ~ .ctl-toggle-box {
    outline: 2px solid #ffb648;
    outline-offset: 2px;
}
.ctl-toggle input:checked ~ .ctl-toggle-label {
    color: #e6e8ee;
}
.ctl-toggle-label {
    color: #c8cdd9;
    transition: color 0.12s;
}


/* --- Custom scrollbars -------------------------------------------------- */
/* Modern, handle-only scrollbars (no top/bottom arrow buttons). Applies to
   the whole document and to any nested scroll container. */

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #3a4154 transparent;
}

/* WebKit / Blink (Chrome, Edge, Safari, Electron) */
*::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
*::-webkit-scrollbar-track {
    background: transparent;
}
*::-webkit-scrollbar-thumb {
    background: #3a4154;
    border-radius: 8px;
    border: 2px solid transparent;
    background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover {
    background: #4a5168;
    background-clip: padding-box;
    border: 2px solid transparent;
}
*::-webkit-scrollbar-thumb:active {
    background: #5a6280;
    background-clip: padding-box;
    border: 2px solid transparent;
}
*::-webkit-scrollbar-corner {
    background: transparent;
}
/* Hide the up/down (and left/right) arrow buttons completely. */
*::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0
}

input[type=number] {
    -moz-appearance:textfield;
}
/* --- Autocomplete suggestion dropdown ---------------------------------- */
.fos-ac {
    position: absolute;
    z-index: 9999;
    display: none;
    max-height: 280px;
    overflow-y: auto;
    background: #161922;
    border: 1px solid #2d3243;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    font-size: 13px;
}
.fos-ac.open { display: block; }
.fos-ac-item {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #1f2330;
    color: #e6e8ee;
}
.fos-ac-item:last-child { border-bottom: none; }
.fos-ac-item.active,
.fos-ac-item:hover { background: #232838; }
.fos-ac-main { font-weight: 500; }
.fos-ac-sub  { font-size: 11px; color: #8a93a8; margin-top: 2px; }
