/* ============================================================================
   Kobciyye CRM - "calm operations console"
   Light, disciplined, institutional. Machine values are monospaced, human
   values are not - that split is the through-line of the whole interface.
   ========================================================================== */

:root {
    color-scheme: light;

    --paper:        #f6f7f9;
    --surface:      #ffffff;
    --surface-alt:  #fbfbfc;

    --ink:          #1b2330;
    --ink-soft:     #59636f;
    --ink-faint:    #8b94a3;

    --line:         #e6e8ec;
    --line-strong:  #d7dae0;

    --accent:       #2e4c86;
    --accent-ink:   #223a69;
    --accent-wash:  #edf1f8;

    --positive:     #1f7a4d;
    --positive-wash:#e7f2ec;
    --warn:         #8a6416;
    --warn-wash:    #f6eedd;
    --negative:     #b23a2f;
    --negative-wash:#f7e9e7;

    --radius:       10px;
    --radius-sm:    7px;
    --shadow:       0 1px 2px rgba(20, 28, 46, .04), 0 6px 20px rgba(20, 28, 46, .04);

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", "Roboto Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

/* --- machine vs human type ------------------------------------------------- */
.mono { font-family: var(--mono); font-size: .92em; }
.num  { font-variant-numeric: tabular-nums; }

/* --- eyebrow / section label -------------------------------------------------*/
.eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

/* ============================================================================
   App frame
   ========================================================================== */
.app {
    display: grid;
    grid-template-columns: 244px 1fr;
    min-height: 100vh;
}

/* --- sidebar ------------------------------------------------------------------*/
.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--line);
}
.sidebar__mark {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 14px;
    flex: none;
}
.sidebar__name { font-weight: 600; letter-spacing: .02em; }
.sidebar__name small {
    display: block;
    font-weight: 500;
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav__group { margin-top: 18px; }
.nav__group:first-child { margin-top: 4px; }
.nav__grouplabel {
    padding: 0 10px 6px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.nav__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    margin: 1px 0;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-weight: 500;
    transition: background .12s ease, color .12s ease;
}
.nav__link:hover { background: var(--surface-alt); color: var(--ink); text-decoration: none; }
.nav__link.is-active { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.nav__link .dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: currentColor; opacity: .55; flex: none;
}
.nav__link.is-active .dot { opacity: 1; }
.nav__badge {
    margin-left: auto;
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--negative);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    line-height: 18px;
}

.sidebar__foot {
    border-top: 1px solid var(--line);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar__avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent-wash); color: var(--accent-ink);
    display: grid; place-items: center;
    font-weight: 600; font-size: 12px;
    text-transform: uppercase;
    flex: none;
}
.sidebar__who { flex: 1; min-width: 0; }
.sidebar__who b { display: block; font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__who span { font-size: 11px; color: var(--ink-faint); }
.linkbtn {
    background: none; border: none; padding: 0;
    color: var(--ink-faint); font: inherit; cursor: pointer;
}
.linkbtn:hover { color: var(--negative); }

/* --- main column -----------------------------------------------------------*/
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 54px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(246, 247, 249, .82);
    backdrop-filter: saturate(180%) blur(6px);
    position: sticky; top: 0; z-index: 5;
}
.crumb { color: var(--ink-faint); font-size: 13px; }
.crumb b { color: var(--ink-soft); font-weight: 600; }
.crumb .sep { margin: 0 8px; color: var(--line-strong); }

.content {
    padding: 30px 32px 64px;
    max-width: 1120px;
    width: 100%;
    animation: rise .28s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* --- page header ---------------------------------------------------------- */
.page-head { margin-bottom: 26px; }
.page-head h1 { font-size: 22px; margin: 6px 0 0; }
.page-head p { margin: 8px 0 0; color: var(--ink-soft); max-width: 62ch; }

/* --- sections ------------------------------------------------------------- */
.section { margin-top: 34px; }
.section__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.section__head h2 { font-size: 14px; }
.section__head .eyebrow { margin-bottom: 2px; }

/* ============================================================================
   Cards, stats, tables
   ========================================================================== */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card--pad { padding: 18px 20px; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat__value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat__label { margin-top: 2px; font-size: 12px; color: var(--ink-soft); }
.stat__value .unit { font-size: 14px; font-weight: 500; color: var(--ink-faint); margin-left: 3px; }
.stat--accent .stat__value { color: var(--accent); }
.stat--warn   .stat__value { color: var(--warn); }
.stat--ok     .stat__value { color: var(--positive); }

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data thead th {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ink-faint);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--line-strong);
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover td { background: var(--surface-alt); }
table.data td.wrap { white-space: normal; }
table.data .num { text-align: right; }
table.data th.num { text-align: right; }

/* key/value table (order details) */
table.kv { width: 100%; border-collapse: collapse; }
table.kv th, table.kv td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.kv th { text-align: left; font-weight: 500; color: var(--ink-soft); width: 200px; }
table.kv tr:last-child th, table.kv tr:last-child td { border-bottom: none; }

/* ============================================================================
   Status tags
   ========================================================================== */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px 3px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 550;
    line-height: 1.4;
}
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.tag--ok      { background: var(--positive-wash); color: var(--positive); }
.tag--pending { background: var(--warn-wash);     color: var(--warn); }
.tag--fail    { background: var(--negative-wash); color: var(--negative); }
.tag--muted   { background: var(--surface-alt);   color: var(--ink-faint); }

/* ============================================================================
   Filing strip - the signature element.
   A ruled band that reads like a routing stamp on a government form: the
   lifecycle of a tax record, left to right, with the reached steps inked in.
   ========================================================================== */
.stamp {
    display: flex;
    flex-wrap: wrap;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background:
        repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), var(--line) calc(25% - 1px) 25%);
    overflow: hidden;
}
.stamp__step {
    flex: 1 1 160px;
    padding: 12px 16px;
    border-right: 1px solid var(--line);
}
.stamp__step:last-child { border-right: none; }
.stamp__k {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.stamp__v { margin-top: 4px; font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.stamp__step.is-done .stamp__k { color: var(--ink-soft); }
.stamp__step.is-done .stamp__v { color: var(--ink); }
.stamp__step.is-done { background: var(--surface); }
.stamp__step.is-current { box-shadow: inset 0 -2px 0 var(--accent); }
.stamp__step.is-reject .stamp__v { color: var(--negative); }

/* ============================================================================
   Filters
   ========================================================================== */
.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px 16px;
    align-items: end;
    padding: 16px 20px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }
.field input, .field select {
    font: inherit;
    padding: 7px 9px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--ink);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.filters .field--action { align-self: end; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font: inherit;
    font-weight: 600;
    padding: 8px 15px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-ink); text-decoration: none; color: #fff; }
.btn--ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn--ghost:hover { background: var(--surface-alt); text-decoration: none; }

/* ============================================================================
   Pagination
   ========================================================================== */
.pager { margin-top: 16px; display: flex; gap: 6px; flex-wrap: wrap; }
.pager a, .pager span {
    min-width: 32px;
    padding: 5px 9px;
    text-align: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
    color: var(--ink-soft);
}
.pager a:hover { background: var(--surface-alt); text-decoration: none; }
.pager .is-current { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ============================================================================
   Empty state
   ========================================================================== */
.empty {
    padding: 40px 24px;
    text-align: center;
    color: var(--ink-soft);
}
.empty b { display: block; color: var(--ink); margin-bottom: 4px; font-weight: 600; }
td .empty { padding: 28px 12px; }

/* ============================================================================
   CRM overview - module grid
   ========================================================================== */
.modules {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.module {
    display: block;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    color: var(--ink);
    transition: border-color .12s ease, transform .12s ease;
}
.module:hover { text-decoration: none; border-color: var(--line-strong); transform: translateY(-1px); }
.module__top { display: flex; align-items: center; justify-content: space-between; }
.module h3 { font-size: 15px; }
.module p { margin: 8px 0 0; color: var(--ink-soft); font-size: 13px; }
.module__stat { margin-top: 14px; font-size: 13px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.module__stat b { color: var(--ink); font-weight: 650; }
.module.is-soon { opacity: .62; pointer-events: none; }

/* ============================================================================
   Auth
   ========================================================================== */
.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(120% 60% at 50% 0%, #eef1f6 0%, var(--paper) 60%);
}
.auth__card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 30px 28px;
}
.auth__brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth__card h1 { font-size: 16px; }
.auth__card h1 small { display: block; font-size: 11px; font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }
.auth__card .field { margin-top: 14px; }
.auth__card .btn { width: 100%; margin-top: 20px; }
.auth__error {
    margin: 4px 0 0;
    padding: 9px 12px;
    background: var(--negative-wash);
    color: var(--negative);
    border-radius: var(--radius-sm);
    font-size: 13px;
}
.auth__error ul { margin: 0; padding-left: 18px; }

/* ============================================================================
   Utilities
   ========================================================================== */
.back { display: inline-flex; align-items: center; gap: 6px; margin-top: 22px; color: var(--ink-soft); font-weight: 500; }
.back:hover { color: var(--accent); text-decoration: none; }
.notice {
    padding: 14px 18px;
    background: var(--warn-wash);
    border: 1px solid #ecdcb6;
    border-radius: var(--radius);
    color: #6f5214;
    font-size: 13px;
}
.stack > * + * { margin-top: 14px; }

/* ============================================================================
   Transactions - raw request / response bodies
   ========================================================================== */
.codebox {
    position: relative;
    margin-top: 12px;
    background: #fbfbfc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.codebox pre {
    margin: 0;
    padding: 16px 18px;
    max-height: 520px;
    overflow: auto;
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ink);
}
.codebox__copy {
    position: absolute;
    top: 8px; right: 8px;
    font: inherit; font-size: 12px; font-weight: 600;
    padding: 3px 10px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    cursor: pointer;
}
.codebox__copy:hover { color: var(--accent); border-color: var(--accent); }
table.data td.excerpt { max-width: 380px; color: var(--ink-faint); }
table.data td.excerpt a { color: inherit; }
table.data td.excerpt a:hover { color: var(--accent); }
table.data tr.is-selected td { background: var(--accent-wash); }
.pager .gap { border-color: transparent; }

/* ============================================================================
   Push jobs - progress
   ========================================================================== */
.progress {
    height: 6px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.progress--lg { height: 10px; }
.progress__bar {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width .4s ease;
}
.progress__meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 13px;
}
.cell-input {
    font: inherit;
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ============================================================================
   Sync service page
   ========================================================================== */
.svc-now {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    flex-wrap: wrap;
}
.svc-state { font-size: 20px; font-weight: 650; margin-top: 4px; }
.svc-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.field .hint { font-size: 11px; color: var(--ink-faint); }

/* Clients / subscriptions */
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions form { display: flex; gap: 4px; align-items: center; margin: 0; }
.btn--sm { padding: 4px 10px; font-size: 12px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-weight: 500;
    border: 1px solid transparent;
}
.tab:hover { background: var(--surface-alt); text-decoration: none; }
.tab.is-active { background: var(--accent-wash); color: var(--accent-ink); border-color: #d9e1f0; }
.tab .mono { color: var(--ink-faint); margin-left: 4px; }
.field textarea {
    font: inherit;
    padding: 7px 9px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--ink);
}

/* ============================================================================
   Responsive - sidebar folds to a horizontal rail
   ========================================================================== */
@media (max-width: 880px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }
    .nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
    .nav__group { margin: 0; }
    .nav__grouplabel { display: none; }
    .nav__link { margin: 0; padding: 6px 11px; }
    .sidebar__foot { border-top: none; }
    .topbar { padding: 0 18px; }
    .content { padding: 22px 18px 48px; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
