/* ============================================================================
   Medikal ERP Pro - app.css
   - mobile-first (360px taban)
   - sidebar mobilde drawer (hamburger ile acilir)
   - tablolar yatay scroll
   - kart bazli layout
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; cursor: default; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--merp-font-sans, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
    color: #0f172a;
    background: #f1f5f9;
    line-height: 1.5;
    font-size: 14px;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }
.text-danger { color: #dc2626; }
.text-muted { color: #64748b; }

/* Erişilebilir gizleme — tüm kabukta (integrations paketine bağlı olmasın) */
.visually-hidden,
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}


/* ---------------- APP SHELL ---------------- */
.app-shell { display: flex; min-height: 100dvh; }
/* merp-ui: yükseklik pro-ui.css'te 100dvh + overflow:hidden (document scroll yok) */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.app-main-stage {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
}
.app-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 16px;
}
.merp-preview-shell {
    display: none;
    flex: 0 0 clamp(300px, 38vw, 520px);
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    background: var(--surface, #fff);
    border-left: 1px solid var(--border, #e2e8f0);
    box-shadow: -2px 0 12px rgba(15, 23, 42, .06);
}
.merp-preview-shell.is-open { display: flex; }
.merp-preview-shell.is-expanded {
    flex: 0 0 clamp(420px, 58vw, 920px);
}
.merp-preview-shell[hidden]:not(.is-open) { display: none !important; }
.merp-preview-slot {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.merp-preview-slot > .card,
.merp-preview-slot > section {
    flex: 1;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    margin: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}
.merp-preview-slot .card-header,
.merp-preview-slot .merp-inline-preview-head {
    flex-shrink: 0;
}
.merp-preview-slot .card-body,
.merp-preview-slot .merp-inline-preview-body,
.merp-preview-slot .einv-preview-body,
.merp-preview-slot .mws-preview-body {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-top: 0;
    -webkit-overflow-scrolling: touch;
}
.merp-preview-slot .expense-preview-image {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: auto !important;
    max-height: none !important;
    object-fit: contain;
}
.merp-preview-slot .merp-inline-preview-frame,
.merp-preview-slot .expense-preview-pdf,
.merp-preview-slot .mws-preview-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: auto !important;
    max-height: none !important;
    border: 0;
    background: #fff;
}
.merp-preview-slot .einv-preview-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
    border: 0;
    background: #fff;
}
.merp-invoice-preview-frame-wrap {
    flex: 0 0 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden !important;
    position: relative;
}
.merp-invoice-preview-scaler {
    display: block;
    position: relative;
    transform-origin: top left;
    -webkit-transform-origin: top left;
    will-change: transform;
}
.merp-preview-slot .einv-preview-body > .merp-invoice-preview-frame-wrap,
.mws-preview-panel .mws-preview-body > .merp-invoice-preview-frame-wrap {
    flex: 0 0 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden !important;
}
/* Ölçeklenen iframe belge genişliğinde kalmalı; width:100% keser. */
.merp-invoice-preview-frame-wrap > .merp-invoice-preview-scaler > .einv-preview-frame,
.merp-invoice-preview-frame-wrap > .merp-invoice-preview-scaler > .mws-preview-frame,
.merp-invoice-preview-frame-wrap > .merp-invoice-preview-scaler > .invoice-preview-frame,
.merp-invoice-preview-frame-wrap > .merp-invoice-preview-scaler > .merp-inline-preview-frame,
.merp-invoice-preview-frame-wrap > .einv-preview-frame,
.merp-invoice-preview-frame-wrap > .mws-preview-frame,
.merp-invoice-preview-frame-wrap > .invoice-preview-frame,
.merp-invoice-preview-frame-wrap > .merp-inline-preview-frame {
    display: block !important;
    position: static !important;
    flex: none !important;
    border: 0;
    background: #fff;
    transform: none !important;
    max-width: none !important;
}
@media (max-width: 1100px) {
    .merp-preview-slot .expense-doc-preview-body,
    .merp-preview-slot .merp-inline-preview-body {
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
    }
    .merp-preview-slot .expense-doc-preview-body iframe.expense-preview-pdf,
    .merp-preview-slot .expense-doc-preview-body .merp-inline-preview-frame,
    .merp-preview-slot .merp-inline-preview-body iframe.expense-preview-pdf,
    .merp-preview-slot .merp-inline-preview-body .merp-inline-preview-frame {
        flex: 1 1 auto;
        min-height: min(60vh, calc(100vh - 12rem));
        min-height: min(60vh, calc(100dvh - 12rem));
        height: 100% !important;
    }
}
.merp-preview-slot .merp-inline-pdf-scroll {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #64748b;
    padding: 8px 0;
}
.merp-preview-slot .merp-inline-pdf-scroll .merp-pdf-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.merp-preview-slot .merp-inline-pdf-scroll .merp-pdf-msg {
    padding: 12px 16px;
    color: #f8fafc;
    font-size: 13px;
}
.merp-preview-slot .merp-inline-pdf-scroll .merp-pdf-msg.is-error {
    color: #fecaca;
}
.merp-preview-slot .merp-inline-probe-msg {
    padding: 12px 16px;
    color: #f8fafc;
    font-size: 13px;
}
@media (max-width: 900px) {
    .app-main-stage { flex-direction: column; }
}
@media (min-width: 768px) and (max-width: 900px) {
    .merp-preview-shell.is-open {
        flex: 0 0 min(52vh, 480px);
        width: 100%;
        max-width: none;
        border-left: none;
        border-top: 1px solid var(--border, #e2e8f0);
        box-shadow: 0 -2px 12px rgba(15, 23, 42, .06);
    }
    .merp-preview-shell.is-expanded {
        flex: 0 0 min(72vh, 640px);
    }
}
.merp-preview-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: calc(var(--merp-z-modal, 1500) - 1);
    background: rgba(15, 23, 42, .45);
}
.merp-preview-backdrop.is-open { display: block; }
body.merp-preview-open { overflow: hidden; }
body.merp-preview-sheet-open { overflow: hidden; }
@media (max-width: 1100px) {
    .merp-preview-shell.is-open {
        position: fixed;
        inset: 0;
        z-index: var(--merp-z-modal, 1500);
        display: flex !important;
        flex: none;
        width: 100%;
        max-width: none;
        min-height: 0;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border: none;
        border-top: none;
        box-shadow: none;
        background: var(--surface, #fff);
    }
    .merp-ui .app-main-stage:has(.einv-desk-v2) .merp-preview-shell.is-open {
        align-self: auto;
        min-height: 0;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
    }
}
/* Mobil tam ekran önizleme: çentik altında kalmasın, Kapat parmakla rahat basılsın */
@media (max-width: 1100px) {
    .merp-preview-shell.is-open {
        padding-top: env(safe-area-inset-top, 0px);
    }
    .merp-preview-shell .merp-preview-close-btn {
        min-width: 2.75rem;
        min-height: 2.75rem;
        padding: 0 .75rem;
    }
}

/* ---------------- PAGE HEADER ---------------- */
.page-header {
    display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px;
    position: relative; z-index: var(--merp-z-page-header, 20);
}
.page-header--compact {
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 8px;
    min-height: 0;
}
.page-header--compact:has(.page-header-leading) {
    justify-content: space-between;
}
.page-header-leading {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.page-header-leading .expense-subnav,
.page-header-leading .cari-subnav {
    margin-bottom: 0;
}
.page-header--compact .page-title { margin: 0; font-size: 18px; line-height: 1.25; }
.page-header--compact .page-subtitle { margin: 2px 0 0; font-size: 12px; }
.page-header--compact .page-header-main:not(:has(.page-title, .page-subtitle, .page-header-badges *)) {
    display: none;
}
.page-header .card-toolbar {
    position: relative; z-index: 2; flex-shrink: 0;
}
.page-title {
    margin: 0;
    font-size: 22px;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.page-subtitle { margin: 4px 0 0; color: #64748b; font-size: 13px; }
.page-header-main { flex: 1; min-width: 0; max-width: 100%; }
.page-header > .merp-breadcrumb-wrap { flex: 1 1 100%; width: 100%; min-width: 0; }
.page-header-badges { margin-bottom: 6px; }
.page-header-actions,
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; }
.merp-action-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-left: auto; }

/* ---------------- CARDS ---------------- */
.card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; margin-bottom: 16px; overflow: visible; }
.card.einv-table-card,
.card.card-overflow-clip { overflow: hidden; }
.card-header { padding: 14px 16px; border-bottom: 1px solid #e2e8f0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; position: relative; z-index: 5; overflow: visible; }
.card-title { margin: 0; font-size: 15px; }
.card-toolbar { display: flex; gap: 6px; flex-wrap: wrap; position: relative; z-index: 6; flex-shrink: 0; }
.card-body { padding: 16px; }
.card-footer { padding: 14px 16px; border-top: 1px solid #e2e8f0; background: #f8fafc; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card-grid {
    display: grid; gap: 12px; margin-bottom: 16px;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.stat-card { background: white; border: 1px solid #e2e8f0; border-radius: 8px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat-card.is-danger { border-color: #fecaca; background: #fef2f2; }
.stat-card.is-danger .stat-value { color: #b91c1c; }
.stat-card.is-warning { border-color: #fde68a; background: #fffbeb; }
.stat-card.is-warning .stat-value { color: #92400e; }
.stat-label { font-size: 12px; color: #64748b; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-value:has(.badge),
.stat-value:has(.merp-badge) { font-size: 1.125rem; font-weight: 650; }
.stat-value--text { font-size: 1rem; font-weight: 650; word-break: break-word; }
.meta-fields,
.detail-list {
    display: grid;
    gap: 1px;
    margin: 0;
    grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr));
    background: var(--border, #e2e8f0);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    overflow: hidden;
}
.card-body.meta-fields,
.card-body.detail-list {
    padding: 0;
    border: 0;
    border-radius: 0;
}
.meta-fields > div,
.detail-list > div {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    min-width: 0;
    margin: 0;
    padding: 0.7rem 0.85rem;
    background: var(--surface, #fff);
    text-align: left;
}
.meta-fields > .meta-fields__full,
.detail-list > .detail-list__full { grid-column: 1 / -1; }
.meta-fields > div > br { display: none; }
.meta-fields > div > small,
.detail-list dt {
    display: block;
    margin: 0;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted, #64748b);
    line-height: 1.3;
}
.meta-fields > div > strong,
.detail-list dd {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 650;
    line-height: 1.35;
    color: var(--merp-text, #0f172a);
    text-align: left;
    word-break: break-word;
}
.meta-fields a,
.detail-list a { font-weight: 650; }
.meta-fields code,
.detail-list code,
.meta-fields__code { word-break: break-all; font-size: 0.8125rem; }
.meta-fields > div > .btn { margin-top: 0.35rem; }
.detail-list + .h4,
.detail-list + .hr-add,
.detail-list + p { margin-top: 0.85rem; }
.release-notes {
    margin: 0;
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.8125rem;
    line-height: 1.5;
    background: color-mix(in srgb, var(--surface, #fff) 86%, var(--border, #e2e8f0));
    padding: 0.85rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border, #e2e8f0);
}
.release-actions { display: flex; flex-direction: column; gap: 0.85rem; }
.release-actions__row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.release-actions .form-grid { align-items: end; }
.release-actions .form-field .btn { align-self: flex-start; }
.release-notes--scroll { max-height: 32rem; overflow: auto; }
.debug-preview-frame {
    width: 100%;
    height: 80vh;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    background: #fff;
}
.code-block {
    margin: 0;
    white-space: pre-wrap;
    overflow: auto;
    max-height: 70vh;
    font-size: 0.8125rem;
    line-height: 1.45;
    padding: 0.85rem 1rem;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
}
.form-field--end { align-self: end; }
.recurring-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: end;
}
.recurring-form .form-field { flex: 1 1 9rem; min-width: 0; margin: 0; }
.field-inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.field-inline > .form-input { flex: 1 1 12rem; min-width: 0; }
.form-input.is-static { display: flex; align-items: center; min-height: 2.5rem; background: var(--surface-muted, #f4f5f7); }
.form-inline { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.input-amount { width: 7.5rem; max-width: 100%; }
.card-body.is-flush { padding: 0; }
.usage-meter { display: flex; align-items: center; gap: 0.5rem; min-width: 7.5rem; }
.usage-meter__track { flex: 1; height: 6px; background: var(--border, #e5e7eb); border-radius: 4px; overflow: hidden; }
.usage-meter__fill { display: block; height: 100%; background: #2563eb; }
.usage-meter__fill.is-hot { background: #dc2626; }
.input-quota { width: 4.5rem; max-width: 100%; }
.int-stat__value--sm { font-size: 0.8125rem; font-weight: 700; }
.note-card { margin: 0 0 0.5rem; padding: 0.65rem 0.75rem; border: 1px solid var(--border, #e2e8f0); border-radius: 8px; }
.alert-list { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.hint-block { margin: 0 0 0.5rem; }
.hint-follow { margin: 0.35rem 0 0; }
.customer-form-readonly { border: 0; margin: 0; padding: 0; min-inline-size: 100%; }
.stat-value.is-ok { color: #16a34a; }
.stat-value.is-bad { color: #dc2626; }
.cell-mono { font-family: ui-monospace, SFMono-Regular, monospace; }
.cell-error { color: #dc2626; }
.narrow-card { max-width: 45rem; margin: 0 auto; }
.card-grid.card-grid--wide { grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr)); }
.input-serial { max-width: 5rem; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; }
.input-narrow { max-width: 5rem; }
.form-grid.kpi-edit { grid-template-columns: repeat(3, minmax(4.5rem, 1fr)) auto; gap: 0.35rem; }
.form-grid.timesheet-edit { grid-template-columns: minmax(4.5rem, 1fr) auto; gap: 0.35rem; }
.code-wrap { word-break: break-all; font-size: 12px; }
.topbar-company-switch .form-input { max-width: 11.25rem; }
.turkey-geo-fields { display: contents; }
.pre-wrap { white-space: pre-wrap; }
col.col-bulk { width: 2.25rem; }
th.bulk-col-check { width: 2rem; }
.bulk-bar[data-bulk-bar] { display: none; }
.scroll-panel { max-height: 20rem; overflow: auto; font-size: 0.8125rem; }
.edefter-check-highlight { background: color-mix(in srgb, #f59e0b 18%, var(--surface, #fff)); }
.recurring-list {
    list-style: none;
    margin: 0.85rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.recurring-list li {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.65rem;
    align-items: center;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    background: var(--surface, #fff);
}
.filing-record-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}
.filing-record-grid .form-stack { gap: 0.65rem; }
.poll-timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.poll-timeline__item {
    padding: 0.5rem 0.75rem;
    border-left: 3px solid var(--merp-primary, #4b59a7);
    background: color-mix(in srgb, var(--surface, #fff) 90%, var(--border, #e2e8f0));
    border-radius: 0 8px 8px 0;
}
.poll-timeline__item--error { border-left-color: #dc2626; }
.poll-timeline__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.65rem;
    align-items: center;
    margin-bottom: 0.15rem;
}
.lot-status-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.lot-status-form .form-input { width: auto; min-width: 10rem; }
.lot-status-form__note { width: 12.5rem; max-width: 100%; }
.uts-lot-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}
.uts-lot-form-extra > summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--merp-text, #334155);
}
.uts-lot-form-extra .form-grid { margin-top: 12px; }
@media (max-width: 640px) {
    .lot-status-form .form-input,
    .lot-status-form__note { width: 100%; min-width: 0; }
}

/* ---------------- TABS ---------------- */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.tab {
    padding: 8px 14px; border-radius: 8px 8px 0 0;
    background: white; border: 1px solid #e2e8f0; border-bottom: none;
    color: #475569; white-space: nowrap; font-size: 13px;
}
.tab:hover { background: #e8eaed; text-decoration: none; }
.tab.is-active { background: #3b82f6; color: white; border-color: #3b82f6; }

/* ---------------- TABLES ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; min-width: 720px; }
.table thead th { background: #f8fafc; padding: 10px 12px; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: #475569; border-bottom: 1px solid #e2e8f0; white-space: nowrap; }
.table tbody td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; font-size: 13px; vertical-align: middle; }
.table.table-striped tbody tr:nth-child(even) { background: #f8fafc; }
.table tbody tr:hover { background: #e8eaed; }
.table-actions { display: inline-flex; gap: 4px; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.table-actions .inline-form { display: inline-flex; margin: 0; }
.table tbody td.col-actions {
    width: 1%;
    white-space: nowrap;
    vertical-align: middle;
}

/* Kompakt veri tabloları + sütun başlığı sıralama */
.table.table-data-compact { min-width: 640px; }
.table.table-data-compact thead th {
    padding: 6px 8px;
    font-size: 11px;
    letter-spacing: .03em;
    vertical-align: bottom;
}
.table.table-data-compact thead th.col-sort { padding: 0; }
.table.table-data-compact tbody td {
    padding: 5px 8px;
    font-size: 12px;
    line-height: 1.35;
    vertical-align: middle;
}
.table.table-data-compact .col-num { text-align: right; white-space: nowrap; }
.table.table-data-compact .col-wide { min-width: 140px; max-width: 220px; }
.table.table-data-compact .col-actions { width: 1%; white-space: nowrap; }
.table.table-data-compact .col-badges { white-space: nowrap; }
.table.table-data-compact .col-badges .badge + .badge { margin-left: 2px; }
.table.table-data-compact .col-codes { min-width: 120px; max-width: 180px; }
.table.table-data-compact .cell-title {
    display: block;
    font-weight: 600;
    color: #0f172a;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}
.table.table-data-compact a.cell-title:hover { color: #2563eb; text-decoration: underline; }
.table.table-data-compact .cell-meta {
    display: block;
    font-size: 11px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table.table-data-compact .cell-code { font-size: 11px; }
.table.table-data-compact .cell-tag {
    display: block;
    font-size: 10px;
    font-family: ui-monospace, monospace;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table.table-data-compact .cell-tag::before {
    display: inline-block;
    width: 2.2em;
    font-size: 9px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
}
.table.table-data-compact .cell-tag[title="GTIN"]::before { content: 'GT'; }
.table.table-data-compact .cell-tag[title="UBB"]::before { content: 'UB'; }
.table.table-data-compact .cell-tag[title="SUT"]::before { content: 'ST'; }
.table.table-data-compact .cell-truncate {
    display: block;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.table.table-data-compact .cell-nowrap { white-space: nowrap; }
.table.table-data-compact .table-actions .btn-xs { padding: 2px 7px; font-size: 11px; }

.table-sort-th {
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-height: 100%;
    padding: 6px 8px;
    color: inherit;
    text-decoration: none;
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
}
.table-sort-th:hover { background: #e8eaed; color: #111827; text-decoration: none; }
.table-sort-th.is-active { background: var(--merp-primary, #4b59a7); color: #fff; }
.table-sort-label { flex: 1; min-width: 0; }
.table-sort-icon {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    opacity: .35;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4-4 4 4M4 10l4 4 4-4' fill='none' stroke='black' stroke-width='1.5'/%3E%3C/svg%3E") center/contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4-4 4 4M4 10l4 4 4-4' fill='none' stroke='black' stroke-width='1.5'/%3E%3C/svg%3E") center/contain no-repeat;
}
.table-sort-th.is-sort-asc .table-sort-icon { opacity: 1; transform: scaleY(-1); }
.table-sort-th.is-sort-desc .table-sort-icon { opacity: 1; }

.badge-xs { padding: 1px 6px; font-size: 10px; line-height: 1.4; }

.badge { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-muted   { background: #f1f5f9; color: #64748b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-converted { background: #ede9fe; color: #5b21b6; }

/* ---------------- BUTTONS ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px;
    background: #f3f4f6; border: 1px solid transparent; border-radius: 8px;
    color: #111827; cursor: pointer; font-size: 13px; font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s, opacity .15s;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover:not(.btn-primary):not(.btn-danger) { background: #e5e7eb; text-decoration: none; }
.btn-primary { background: var(--mx-primary, var(--merp-primary, #4b59a7)); border-color: transparent; color: white; }
.btn-primary:hover { background: color-mix(in srgb, var(--mx-primary, var(--merp-primary, #4b59a7)) 82%, #000); border-color: transparent; color: #fff; }
.btn-secondary { background: #f3f4f6; border-color: transparent; }
.btn-danger { background: #dc2626; border-color: transparent; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-block { width: 100%; }
.btn-sm, .btn-xs { padding: 6px 12px; font-size: 13px; min-height: 2rem; }
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- FORMS ---------------- */
.form-stack { display: flex; flex-direction: column; gap: 0; }
.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.form-field { display: flex; flex-direction: column; gap: 6px; -webkit-user-select: text; user-select: text; }
.form-label, .form-hint, .toggle-label, .settings-workspace, .settings-panel,
.integrations-page, .integrations-workspace, .acc-settings-group {
    -webkit-user-select: text;
    user-select: text;
}
.form-field-full { grid-column: 1 / -1; }
.form-label { font-size: 12px; color: #475569; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.req { color: #dc2626; }
.form-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #e5e7eb; border-radius: 8px;
    font-size: 14px; font-family: inherit;
    background: white;
    color: #111827;
}
.form-input:focus { outline: none; border-color: #d1d5db; box-shadow: none; }
.form-input:disabled { background: #f1f5f9; color: #64748b; cursor: not-allowed; }
.form-input[readonly],
input.form-input[readonly] {
    background: #f1f5f9;
    color: #0f172a;
    cursor: text;
    -webkit-user-select: text;
    user-select: text;
}
.form-input.is-invalid { border-color: #dc2626; outline-color: #dc2626; }
.merp-phone-field {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
}
.merp-phone-field__dial {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 0 22px 0 10px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
    font-size: 13px;
    font-weight: 650;
    line-height: 1;
    user-select: none;
    cursor: pointer;
}
.merp-phone-field__dial::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 50%;
    width: 6px;
    height: 6px;
    border-right: 1.6px solid currentColor;
    border-bottom: 1.6px solid currentColor;
    transform: translateY(-70%) rotate(45deg);
    opacity: 0.5;
    pointer-events: none;
}
.merp-phone-field select.merp-phone-field__select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
    border: 0;
    background: transparent !important;
    background-image: none !important;
    appearance: auto;
    -webkit-appearance: menulist;
    font-size: 16px;
}
.merp-phone-field__flag {
    display: block;
    width: 22px;
    height: 15px;
    flex: 0 0 auto;
    border-radius: 2px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
}
.merp-phone-field__flag--emoji {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    overflow: visible;
    box-shadow: none;
}
.merp-phone-field__code {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}
.merp-phone-field__number {
    flex: 1 1 auto;
    min-width: 16ch;
    width: auto;
}
select.form-input:not(.ss-native) {
    appearance: none;
    padding-right: 36px;
    background-image:
        linear-gradient(45deg, transparent 50%, #64748b 50%),
        linear-gradient(135deg, #64748b 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 50%,
        calc(100% - 12px) 50%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}
.form-check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; padding: 8px 0; }
.form-check input[type="checkbox"] { margin-top: 2px; }

.toggle-field {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-height: 40px;
    padding: 8px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    width: fit-content;
    max-width: 100%;
    margin: 0;
}
.form-field .toggle-field { margin-top: 8px; }
.toggle-field.form-field-full {
    width: 100%;
    grid-column: 1 / -1;
}
.toggle-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
}
.toggle-switch {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background 0.2s ease;
}
.toggle-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15);
    transition: transform 0.2s ease;
}
.toggle-input:checked + .toggle-switch {
    background: var(--merp-primary, #4f46e5);
}
.toggle-input:checked + .toggle-switch::after {
    transform: translateX(18px);
}
.toggle-input:focus-visible + .toggle-switch {
    outline: none;
}
.toggle-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--merp-text, #0f172a);
    line-height: 1.3;
}
.form-hint { color: #64748b; font-size: 12px; }
.form-split-block {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border, #e2e8f0);
    padding-top: 16px;
    margin-top: 4px;
}
.form-split-block > .form-field { margin-top: 12px; }
.form-check--block {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 8px 0;
}
.form-error { color: #dc2626; font-size: 12px; font-weight: 500; }
.form-chip { background: #fee2e2; color: #991b1b; padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 500; margin-left: 4px; }


/* Detay bilgi ızgarası: .meta-fields ve .detail-list yukarıda tanımlı. */

/* Global loading overlay */
.merp-loading { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; pointer-events: all; }
.merp-loading.is-on { pointer-events: all; }
.merp-loading[hidden] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    -webkit-transform: none !important;
    transform: none !important;
}
.merp-loading-backdrop {
    position: absolute; inset: 0;
    background: rgba(15, 23, 42, .5);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    backdrop-filter: blur(16px) saturate(1.2);
}
.merp-loading-core {
    position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .9rem; text-align: center;
    padding: 0;
    min-width: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    opacity: 1;
}
.merp-spinner-stage {
    position: relative;
    width: 156px; height: 156px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .28);
}
.merp-spinner-ring {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    border: 3px solid rgba(30, 58, 138, .14);
    border-top-color: #1e3a8a;
    border-right-color: #0f9f8f;
    animation: merp-spin 1s linear infinite;
}
.merp-spinner {
    position: relative; z-index: 1;
    width: 78px; height: 86px; margin: 0; border: 0; border-radius: 0;
    background: url('midas-mark.png') center / contain no-repeat;
    box-shadow: none;
    animation: merp-spin 2.4s linear infinite reverse;
}
.merp-spinner.is-mark {
    width: 74px; height: 86px; overflow: hidden;
    background-size: auto 100%;
    background-position: left center;
    background-repeat: no-repeat;
}
.merp-spinner.is-icon {
    width: 84px; height: 84px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}
@keyframes merp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .merp-spinner,
    .merp-spinner-ring { animation: none; }
}
.merp-loading-text { margin: 0; font-size: .9375rem; color: #fff; font-weight: 500; letter-spacing: .04em; text-shadow: 0 1px 2px rgba(15, 23, 42, .45), 0 8px 22px rgba(15, 23, 42, .35); }
.merp-loading-hint {
    margin: 0;
    max-width: 32ch;
    font-size: .8125rem;
    line-height: 1.45;
    color: rgba(255, 255, 255, .85);
}
.merp-loading-hint[hidden],
.merp-loading-dismiss[hidden] { display: none !important; }
.merp-loading-dismiss {
    margin-top: 2px;
    padding: 8px 18px;
    border: 0;
    border-radius: 8px;
    background: #f3f4f6;
    color: #111827;
    font: inherit;
    font-size: .8125rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
}

/* Native WebView: spinner native overlay/klavye altında kalmasın (biyometri 2147483000).
   translate3d yalnızca görünürken; gizli katman WKWebView'da ekranda kalıyordu. */
html.midas-native-app .merp-loading {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147482000;
}
html.midas-native-app .merp-loading.is-on {
    -webkit-transform: none;
    transform: none;
}
html.midas-native-app .merp-loading[hidden] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    -webkit-transform: none !important;
    transform: none !important;
}

/* ---------------- FLASH ---------------- */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: 8px;
    background: #f1f5f9; border-left: 4px solid #64748b;
    font-size: 14px;
}
.flash-success { background: #dcfce7; border-left-color: #16a34a; color: #14532d; }
.flash-error   { background: #fee2e2; border-left-color: #dc2626; color: #7f1d1d; }
.flash-warning { background: #fef3c7; border-left-color: #f59e0b; color: #78350f; }
.flash-info    { background: #dbeafe; border-left-color: #2563eb; color: #1e3a8a; }
.flash-message { flex: 1; }
.flash-close {
    box-sizing: border-box;
    width: 32px;
    height: 32px;
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    opacity: 1;
    color: #4b5563;
}
.flash-close:hover { background: #e8eaed; color: #111827; }

/* ---------------- TOAST (JS bildirimleri) ---------------- */
.merp-toast-stack {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 12000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(420px, calc(100vw - 32px));
    pointer-events: none;
}
.merp-toast {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: none;
    background: #1e293b;
    color: #f8fafc;
    opacity: 1;
    transform: translateY(0);
    transition: opacity .25s ease, transform .25s ease;
}
.merp-toast--error { background: #7f1d1d; }
.merp-toast--ok { background: #14532d; }
.merp-toast--closable {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.merp-toast-body { flex: 1; min-width: 0; }
.merp-toast-close {
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: inherit;
    font-size: 20px;
    line-height: 1;
    padding: 0 0 0 4px;
    cursor: pointer;
    opacity: 0.85;
}
.merp-toast-close:hover { opacity: 1; }
.merp-toast.is-out { opacity: 0; transform: translateY(8px); }

/* ---------------- EMPTY ---------------- */
.empty-state { text-align: center; padding: 32px 16px; color: #64748b; }

/* ---------------- CALLOUT ---------------- */
.callout {
    padding: 12px 16px;
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
    font-size: 13px; margin-bottom: 16px;
}
.callout code { background: white; }

/* ---------------- SEARCH ---------------- */
.search-results {
    display: grid;
    gap: 8px;
}
.search-result-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 4px 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    color: #0f172a;
}
.search-result-item:hover {
    background: #e8eaed;
    text-decoration: none;
}
.search-result-item small {
    grid-column: 2;
    color: #64748b;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (min-width: 480px) {
    .app-content { padding: 20px; }
    .merp-ui .app-content { padding-top: 0; }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid .span-2 { grid-column: span 2; }
    .page-header { flex-direction: row; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
    .page-header:has(.page-header-actions) .page-header-main,
    .page-header:has(.page-header-actions) .page-header-actions {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
    }
}
@media (min-width: 768px) {
    .detail-grid { grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr); }
    .crm-contact-edit-layout { grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr); }
    .topbar--has-search .topbar-search { display: block; }
}
@media (min-width: 1024px) {
    .page-header:has(.page-header-actions) .page-header-main {
        flex: 1 1 auto;
        width: auto;
    }
    .page-header:has(.page-header-actions) .page-header-actions {
        flex: 0 0 auto;
        width: auto;
        max-width: min(62vw, 52rem);
        justify-content: flex-end;
    }
    .topbar {
        padding: 0 20px;
        gap: 12px;
    }
    .topbar-main {
        flex: 0 1 560px;
    }
    .topbar-quick-access--rail {
        display: none !important;
    }
    .topbar-quick-menu {
        display: block;
    }
}
@media (max-width: 1023px) {
    .topbar-start,
    .topbar-end {
        flex: 0 0 auto;
    }
    .topbar-main {
        flex: 1 1 auto;
        max-width: none;
        justify-content: stretch;
    }
    .topbar-quick-menu {
        display: none !important;
    }
}
@media (min-width: 1024px) {
    /* Desktop: sidebar always visible */
    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        transform: none;
        flex-shrink: 0;
    }
    .sidebar-overlay { display: none !important; }
    .sidebar-close { display: none; }
    .topbar-hamburger { display: none; }
    .topbar-context { display: flex; }
    .topbar-start { gap: 10px; }
    .app-content { padding: 24px; }
    .merp-ui .app-content { padding-top: 0; }
    .form-grid { grid-template-columns: repeat(3, 1fr); }
    .form-grid .span-2 { grid-column: span 2; }
}

/* ---- badge-info (from einvoice-desk) ---- */
.badge-info { background: #eef0f8; color: var(--merp-primary, #4b59a7); }

/* ---- callout variants + form-hint-inline (from einvoice-desk) ---- */
.callout-success { border-color: #86efac; background: #f0fdf4; }
.callout-warning { border-color: #fcd34d; background: #fffbeb; }
.callout-info { border-color: #93c5fd; background: #eff6ff; color: #1e40af; }
.callout-danger { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.form-hint-inline { font-weight: 400; color: var(--muted, #64748b); font-size: .8125rem; }
label.form-label { cursor: pointer; }
.ux-disclosure { margin-top: 12px; }
.ux-disclosure > summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.ux-card-disclosure > summary { list-style: none; cursor: pointer; }
.ux-card-disclosure > summary::-webkit-details-marker { display: none; }
.ux-card-disclosure > summary.qw-card__head { display: flex; align-items: center; }
/* Açılır kart başlığında ok işareti yoktu; kapalı kartın açılabildiği anlaşılmıyordu */
.ux-card-disclosure > summary.qw-card__head::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); opacity: .55; transition: transform .15s; }
.ux-card-disclosure[open] > summary.qw-card__head::after { transform: rotate(225deg); }
.ux-confirm { position: fixed; inset: 0; z-index: 8000; display: flex; align-items: center; justify-content: center; padding: 16px; }
.ux-confirm[hidden] { display: none; }
.ux-confirm__backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .42); }
.ux-confirm__panel { position: relative; z-index: 1; width: min(420px, 100%); background: var(--merp-surface, #fff); color: var(--merp-text, #0f172a); border: 1px solid var(--merp-border, #e2e8f0); border-radius: 12px; padding: 16px; }
.ux-confirm__text { margin: 0 0 14px; font-size: 15px; line-height: 1.45; }
.ux-confirm__field { display: block; margin: 0 0 14px; }
.ux-confirm__field[hidden] { display: none; }
.ux-confirm__field .form-input { width: 100%; min-height: 40px; }
.ux-confirm__actions { display: flex; justify-content: flex-end; gap: 8px; }
body.ux-confirm-open { overflow: hidden; }
.einv-mobile-more { position: relative; }
.einv-mobile-more > summary { list-style: none; }
/* Simge-butonu font-size:0 alıyor; "···" metni görünmüyordu */
.merp-ui .einv-mobile-more > summary.einv-mobile-action-btn { font-size: 15px !important; line-height: 1 !important; font-weight: 700; letter-spacing: -1px; }
.einv-mobile-more > summary::-webkit-details-marker { display: none; }
.einv-mobile-more__panel { position: absolute; right: 0; top: calc(100% + 4px); z-index: 5; display: flex; gap: 4px; padding: 6px; background: var(--merp-surface, #fff); border: 1px solid var(--merp-border, #e2e8f0); border-radius: 8px; }

/* Mobil klavye açık (app.js html.merp-kb-open): sabit alt çubuklar alanları örtmesin,
   içerik klavye yüksekliği kadar kaydırılabilsin. */
html.merp-kb-open .px-mobile-bar,
html.merp-kb-open .iw-wizard .qw-action-bar,
html.merp-kb-open .merp-form-sticky-footer { display: none !important; }
html.merp-kb-open body:not(#_),
html.merp-kb-open body .app-shell:not(#_) { height: var(--merp-vv-h, 100%) !important; min-height: 0 !important; max-height: var(--merp-vv-h, 100%) !important; }
html.merp-kb-open body .app-content:not(#_) { padding-bottom: 16px !important; transition: none !important; }
html.merp-kb-open .iw-steps { position: static !important; }
