/* MCORE-FAYL (#551–#555): yalnız tokens.css dəyişənləri (web_theme_check = 0). Tünd rejim = tokens.css-in html[data-theme=dark] filtri. */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0; background: var(--c-surface-2); color: var(--c-text);
    font: 400 14px/1.45 Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--c-blue-500); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--c-surface); padding: 8px 12px; border-radius: var(--r-md); }
.skip:focus { left: 8px; }
.spacer { flex: 1; }
.boot { display: flex; align-items: center; gap: 10px; justify-content: center; height: 100vh; color: var(--c-text-2); font-size: var(--fs-lg); }
.app { min-height: 100%; }

/* ── düymələr / sahələr ── */
.mf-btn {
    display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: var(--r-md);
    border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-text); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.mf-btn:hover { background: var(--c-surface-4); }
.mf-btn.primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-surface); }
.mf-btn.primary:hover { filter: brightness(1.08); }
.mf-btn.danger { background: var(--c-danger-4); border-color: var(--c-danger-4); color: var(--c-surface); }
.mf-btn.danger-ghost { color: var(--c-danger-text); }
.mf-btn.small { height: 28px; padding: 0 9px; font-size: var(--fs-sm); }
.mf-btn.big { height: 46px; padding: 0 20px; font-size: var(--fs-lg); border-radius: var(--r-lg); }
.mf-btn[hidden] { display: none; }
.mf-icon-btn {
    display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: var(--r-md);
    background: transparent; color: var(--c-text-2); cursor: pointer; flex: 0 0 auto;
}
.mf-icon-btn:hover { background: var(--c-surface-4); color: var(--c-text); }
.mf-icon-btn.tiny { width: 24px; height: 24px; font-size: var(--fs-xs); }
.mf-lang { font-size: var(--fs-xs); font-weight: 700; letter-spacing: .04em; }
.mf-input {
    width: 100%; min-height: 36px; padding: 6px 10px; border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface);
    font-size: 16px;
}
@media (min-width: 761px) { .mf-input { font-size: var(--fs-md); } }
.mf-input:focus { outline: 2px solid var(--c-accent); outline-offset: 0; border-color: var(--c-accent); }
.mf-input.num { text-align: right; font-variant-numeric: tabular-nums; }
.mf-input.ro { display: flex; align-items: center; background: var(--c-surface-3); color: var(--c-text-2); }
.mf-input.mono { font-family: ui-monospace, Consolas, monospace; }
textarea.mf-input { resize: vertical; }
.mf-label { display: block; font-size: var(--fs-sm); color: var(--c-text-2); margin: 10px 0 4px; font-weight: 500; }
.mf-hint { color: var(--c-text-3); font-size: var(--fs-sm); margin: 6px 0; }
.mf-hint.ok { color: var(--c-success-text); }
.mf-err { color: var(--c-danger-text); font-size: var(--fs-sm); margin: 6px 0; min-height: 0; }
.mf-msg { margin: 0 0 8px; line-height: 1.55; }
.mf-affix { display: flex; align-items: stretch; }
.mf-affix .mf-input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.mf-affix span { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--c-line); border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--c-surface-4); color: var(--c-text-2); }
.mf-switch { width: 20px; height: 20px; accent-color: var(--c-accent); }
.g-req { color: var(--c-danger-text); font-weight: 700; margin-left: 2px; }
.g-count { display: inline-block; min-width: 22px; padding: 0 7px; border-radius: 10px; background: var(--c-surface-4); color: var(--c-text-2); font-size: var(--fs-xs); font-weight: 600; text-align: center; margin-left: 6px; }

/* ── brend / başlanğıc ── */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--c-text); text-decoration: none; font-size: var(--fs-xl); }
.brand b { color: var(--c-accent); }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: var(--r-md); background: var(--c-navy); color: var(--c-surface); font-size: 16px; }
.brand.small .brand-mark { width: 30px; height: 30px; }
.home { max-width: 1080px; margin: 0 auto; padding: 0 16px 40px; }
.home-top { display: flex; align-items: center; gap: 8px; padding: 14px 0; }
.home-hero { padding: 28px 0 10px; }
.home-hero h1 { font-size: clamp(26px, 4vw, 40px); line-height: 1.15; margin: 0 0 12px; letter-spacing: -.02em; }
.home-hero .lead { font-size: var(--fs-lg); color: var(--c-text-2); max-width: 720px; margin: 0 0 16px; }
.home-points { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-wrap: wrap; gap: 10px 22px; color: var(--c-text-6); }
.home-points i { color: var(--c-accent); margin-right: 6px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.home-card { background: var(--c-surface); border: 1px solid var(--c-line-soft); border-radius: var(--r-lg); padding: 16px 18px; margin-top: 18px; box-shadow: var(--sh-1); }
.home-card h2 { font-size: var(--fs-lg); margin: 0 0 12px; }
.home-card.warn { border-color: var(--c-warning); }
.home-card .row { display: flex; gap: 8px; flex-wrap: wrap; }
.home-foot { color: var(--c-text-3); font-size: var(--fs-sm); margin-top: 26px; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--c-line-soft); }
.recent li:first-child { border-top: 0; }
.recent-open { flex: 1; display: flex; align-items: center; gap: 12px; padding: 10px 6px; border: 0; background: none; cursor: pointer; text-align: left; border-radius: var(--r-md); }
.recent-open:hover { background: var(--c-surface-4); }
.recent-open i { color: var(--c-accent); font-size: 18px; }
.recent-open span { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.recent-open small { color: var(--c-text-3); }
.recent-open .when { flex: 0 0 auto; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.tpl {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px; border: 1px solid var(--c-line-soft); border-radius: var(--r-lg);
    background: var(--c-surface); cursor: pointer; text-align: left; min-height: 108px;
}
.tpl:hover { border-color: var(--c-accent); box-shadow: var(--sh-2); }
.tpl small { color: var(--c-text-3); font-size: var(--fs-sm); }
.tpl-ic { width: 34px; height: 34px; border-radius: var(--r-md); background: var(--c-surface-6); color: var(--c-accent); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 4px; }

/* ── redaktor ── */
.editor { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--c-surface); border-bottom: 1px solid var(--c-line-soft); flex-wrap: nowrap; }
.doc-title { border: 1px solid transparent; background: transparent; font-size: var(--fs-lg); font-weight: 600; padding: 4px 8px; border-radius: var(--r-md); min-width: 80px; width: 26ch; max-width: 40vw; }
.doc-title:hover, .doc-title:focus { border-color: var(--c-line); background: var(--c-surface); outline: none; }
.save-status { font-size: var(--fs-sm); color: var(--c-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.save-status.dirty { color: var(--c-warning); }
.save-status.ok { color: var(--c-success-text); }
.ed-body { flex: 1; display: flex; min-height: 0; }
.side { width: 230px; flex: 0 0 230px; background: var(--c-surface); border-right: 1px solid var(--c-line-soft); padding: 10px 8px; display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.tbl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.tbl-list li { display: flex; align-items: center; }
.tbl-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-md); background: none; cursor: pointer; text-align: left; }
.tbl-btn:hover { background: var(--c-surface-4); }
.tbl-btn.on { background: var(--c-surface-6); color: var(--c-accent); font-weight: 600; }
.tbl-btn i { width: 18px; text-align: center; color: var(--c-text-3); }
.tbl-btn.on i { color: var(--c-accent); }
.tbl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.add-tbl { justify-content: center; border-style: dashed; color: var(--c-text-2); }
.ed-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--c-surface-2); flex-wrap: wrap; }
.toolbar .search { width: 240px; min-height: 34px; }
.toolbar .sep { width: 1px; height: 22px; background: var(--c-line); margin: 0 2px; }
.grid-host { flex: 1; min-height: 0; padding: 0 10px; display: flex; }
.statusbar { padding: 6px 14px; font-size: var(--fs-sm); color: var(--c-text-3); border-top: 1px solid var(--c-line-soft); background: var(--c-surface); min-height: 30px; }

/* ── grid ── */
.g { position: relative; flex: 1; min-width: 0; display: flex; border: 1px solid var(--c-line-soft); border-radius: var(--r-lg); background: var(--c-surface); overflow: hidden; }
.g:focus { outline: none; }
.g:focus-visible { box-shadow: 0 0 0 2px var(--c-accent); }
.g-scroll { flex: 1; overflow: auto; position: relative; }
.g-head { position: sticky; top: 0; z-index: 3; background: var(--c-surface-3); min-width: max-content; }
.g-hrow, .g-frow { display: flex; border-bottom: 1px solid var(--c-line-soft); }
.g-hcell { position: relative; display: flex; align-items: center; height: 38px; border-right: 1px solid var(--c-line-soft); font-weight: 600; font-size: var(--fs-sm); color: var(--c-text-6); flex: 0 0 auto; }
.g-hcell.drop { box-shadow: inset 3px 0 0 var(--c-accent); }
.g-hcell.g-sel, .g-fcell.g-sel { justify-content: center; color: var(--c-text-4); }
.g-hlabel { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; gap: 5px; padding: 0 4px 0 10px; border: 0; background: none; cursor: pointer; font-weight: 600; text-align: left; overflow: hidden; }
.g-hlabel span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-hlabel i { color: var(--c-text-4); font-size: var(--fs-xs); }
.g-hlabel .fa-arrow-up-short-wide, .g-hlabel .fa-arrow-down-wide-short { color: var(--c-accent); }
.g-hcell.r .g-hlabel { justify-content: flex-end; }
.g-hmenu { width: 24px; height: 28px; border: 0; background: none; color: var(--c-text-4); cursor: pointer; border-radius: var(--r-sm); opacity: .6; }
.g-hcell:hover .g-hmenu, .g-hmenu:focus { opacity: 1; }
.g-hmenu:hover { background: var(--c-surface-4); color: var(--c-text); }
.g-resize { position: absolute; right: -4px; top: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 2; }
.g-resize:hover { background: var(--c-accent); opacity: .35; }
.g-fcell { flex: 0 0 auto; height: 32px; padding: 3px 4px; border-right: 1px solid var(--c-line-soft); display: flex; align-items: center; }
.g-filter { width: 100%; height: 24px; border: 1px solid var(--c-line-soft); border-radius: var(--r-sm); padding: 0 6px; font-size: var(--fs-sm); background: var(--c-surface); }
.g-filter:focus { outline: 2px solid var(--c-accent); outline-offset: -1px; }
.g-body { position: relative; min-width: max-content; }
.g-row { position: absolute; left: 0; display: flex; height: 34px; border-bottom: 1px solid var(--c-line-soft); background: var(--c-surface); }
.g-row.odd { background: var(--c-surface-9); }
.g-row:hover { background: var(--c-surface-6); }
.g-row.sel { background: var(--c-surface-8); box-shadow: inset 3px 0 0 var(--c-accent); }
.g-cell { flex: 0 0 auto; display: flex; align-items: center; padding: 0 10px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border-right: 1px solid var(--c-line-soft); font-size: var(--fs-md); }
.g-cell > span, .g-cell > a { overflow: hidden; text-overflow: ellipsis; }
.g-cell.r { justify-content: flex-end; font-variant-numeric: tabular-nums; }
.g-cell.act { outline: 2px solid var(--c-accent); outline-offset: -2px; background: var(--c-surface); }
.g-cell.g-sel { justify-content: center; padding: 0; }
.g-cell input[type=checkbox], .g-hcell input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--c-accent); cursor: pointer; }
.g-group { background: var(--c-surface-7) !important; font-weight: 600; cursor: pointer; }
.g-total { position: relative; background: var(--c-surface-3); font-weight: 600; border-top: 2px solid var(--c-line); }
.g-foot { position: sticky; bottom: 0; z-index: 2; min-width: max-content; }
.g-foot .g-row { position: relative; }
.g-empty { position: absolute; left: 0; right: 0; top: 96px; text-align: center; color: var(--c-text-3); padding: 20px; pointer-events: none; }
.g-bool { color: var(--c-text-4); font-size: 16px; cursor: pointer; }
.g-bool.on { color: var(--c-accent); }
.g-img { color: var(--c-text-3); }
.g-link { color: var(--c-blue-500); }
.g-err { color: var(--c-danger-text); font-weight: 600; }
.neg { color: var(--c-danger-text); }
.g-editor { position: absolute; z-index: 4; border: 2px solid var(--c-accent); border-radius: 0; padding: 0 8px; background: var(--c-surface); font-size: var(--fs-md); box-shadow: var(--sh-2); }

/* ── dialoq / menyu / bildiriş ── */
.mf-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .42); display: flex; align-items: center; justify-content: center; padding: 16px; }
.mf-dialog { background: var(--c-surface); border-radius: var(--r-lg); box-shadow: var(--sh-3); width: min(520px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.mf-dialog.wide { width: min(880px, 100%); }
.mf-dialog-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 6px; }
.mf-dialog-head h2 { flex: 1; margin: 0; font-size: var(--fs-xl); }
.mf-dialog-body { padding: 6px 16px 12px; overflow: auto; }
.mf-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--c-line-soft); flex-wrap: wrap; }
body.mf-modal-open { overflow: hidden; }
.mf-menu { position: fixed; z-index: 60; min-width: 220px; max-width: 320px; max-height: 70vh; overflow: auto; background: var(--c-surface); border: 1px solid var(--c-line-soft); border-radius: var(--r-md); box-shadow: var(--sh-3); padding: 4px; }
.mf-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; text-align: left; border-radius: var(--r-sm); cursor: pointer; }
.mf-menu-item:hover, .mf-menu-item:focus { background: var(--c-surface-6); outline: none; }
.mf-menu-item:disabled { opacity: .45; cursor: default; }
.mf-menu-item i, .mf-menu-ic { width: 16px; text-align: center; color: var(--c-text-3); }
.mf-menu-item.danger, .mf-menu-item.danger i { color: var(--c-danger-text); }
.mf-menu-label { flex: 1; }
.mf-menu-item kbd { font: var(--fs-xs) Inter, sans-serif; color: var(--c-text-4); }
.mf-menu-sep { height: 1px; background: var(--c-line-soft); margin: 4px 2px; }
.mf-toasts { position: fixed; z-index: 70; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; max-width: min(440px, calc(100vw - 32px)); }
.mf-toast { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-radius: var(--r-md); background: var(--c-slate-850); color: var(--c-surface); box-shadow: var(--sh-3); font-size: var(--fs-md); }
.mf-toast > span { flex: 1; }
.mf-toast.ok i:first-child { color: var(--c-success-2); }
.mf-toast.error { background: var(--c-danger-4); }
.mf-toast .mf-icon-btn { color: var(--c-surface); }
.mf-toast .mf-btn { height: 28px; }
.mig-prog { display: flex; align-items: center; gap: 10px; flex: 1; }
.mig-prog progress { flex: 1; }

/* ── kart ── */
.card-dialog .mf-dialog-body { padding-top: 0; }
.card-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 4px 0 10px; border-bottom: 1px solid var(--c-line-soft); margin-bottom: 6px; position: sticky; top: 0; background: var(--c-surface); z-index: 1; }
.card-meta { color: var(--c-text-3); font-size: var(--fs-sm); }
.card-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.card-field { min-width: 0; position: relative; }
.card-field.wide { grid-column: 1 / -1; }
.card-field.t-bool { display: flex; align-items: center; gap: 10px; padding-top: 26px; }
.card-field.t-bool .mf-label { order: 2; margin: 0; }
.card-hint { color: var(--c-text-4); font-size: var(--fs-xs); font-family: ui-monospace, Consolas, monospace; }
.card-form.arrange .card-field { border: 1px dashed var(--c-line); border-radius: var(--r-md); padding: 4px 8px 8px; margin: 4px 0; cursor: grab; }
.card-form.arrange .card-field.drop { border-color: var(--c-accent); background: var(--c-surface-6); }
.card-form.arrange .card-field.dragging { opacity: .5; }
.card-arrange { display: flex; align-items: center; gap: 2px; color: var(--c-text-4); }
.card-bc { display: flex; flex-direction: column; gap: 4px; }
.card-barcode { max-width: 100%; height: 56px; background: var(--c-surface); }
.card-image { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.card-image img { max-width: 220px; max-height: 160px; border-radius: var(--r-md); border: 1px solid var(--c-line-soft); object-fit: contain; background: var(--c-surface-3); }
.card-noimg { width: 160px; height: 110px; border: 1px dashed var(--c-line); border-radius: var(--r-md); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--c-text-4); }
.card-image-btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* ── idxal / köçürmə / sahə ── */
.imp-row { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center; }
.imp-row .mf-label { margin: 0; }
.imp-table-wrap { max-height: 46vh; overflow: auto; border: 1px solid var(--c-line-soft); border-radius: var(--r-md); }
.imp-table { width: 100%; border-collapse: collapse; }
.imp-table th, .imp-table td { padding: 6px 8px; border-bottom: 1px solid var(--c-line-soft); text-align: left; vertical-align: top; font-size: var(--fs-md); }
.imp-table th { color: var(--c-text-2); font-weight: 600; background: var(--c-surface-3); }
.imp-sample { color: var(--c-text-3); font-size: var(--fs-xs); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mig-table { border: 1px solid var(--c-line-soft); border-radius: var(--r-md); margin: 10px 0; padding: 8px 12px 10px; }
.mig-table legend { font-weight: 600; padding: 0 6px; }
.mig-consent { display: flex; align-items: center; gap: 8px; margin: 12px 0 4px; cursor: pointer; }
.mig-consent input { width: 18px; height: 18px; accent-color: var(--c-accent); }
.mig-docs, .mig-warn { padding-left: 4px; list-style: none; }
.mig-docs li, .mig-warn li { margin: 6px 0; }
.mig-warn i { color: var(--c-warning); }
.fld-row { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: end; }
.fx-help { margin: 8px 0; font-size: var(--fs-sm); color: var(--c-text-2); }
.fx-help p { margin: 4px 0; font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-xs); }

/* ── telefon / planşet ── */
@media (max-width: 760px) {
    .topbar { flex-wrap: wrap; padding: 6px 8px; }
    .doc-title { width: auto; flex: 1; max-width: none; }
    .save-status { order: 9; flex-basis: 100%; max-width: none; }
    .lbl { display: none; }
    .ed-body { flex-direction: column; }
    .side { width: auto; flex: 0 0 auto; flex-direction: row; border-right: 0; border-bottom: 1px solid var(--c-line-soft); overflow-x: auto; padding: 6px; }
    .tbl-list { flex-direction: row; }
    .tbl-btn { white-space: nowrap; }
    .add-tbl { flex: 0 0 auto; }
    .toolbar .search { width: 100%; order: -1; }
    .grid-host { padding: 0 4px; }
    .card-form { grid-template-columns: 1fr; }
    .mf-dialog { max-height: calc(100dvh - 16px); }
    .mf-backdrop { padding: 8px; }
    .imp-row { grid-template-columns: 1fr; }
}
@media print { .topbar, .side, .toolbar, .statusbar { display: none; } }
