:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel-2: #f9fafb; --text: #1b1f24; --muted: #6b7280; --line: #e5e7eb;
  --accent: #d6201f; --accent-2: #b51616; --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2; --info: #1d4ed8; --info-bg: #dbeafe; --test: #ea580c; --real: #15803d;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --panel-2: #1d212a; --text: #e6e8eb; --muted: #9aa3ae; --line: #2a2f3a;
    --ok-bg: #12331f; --warn-bg: #3a2a0c; --bad-bg: #3b1515; --info-bg: #142449; --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: grid; gap: 14px; }
.login-card label { display: grid; gap: 6px; font-weight: 500; }
.err { color: var(--bad); min-height: 18px; }

/* layout */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 13px; }
.mode-pill { text-align: center; font-weight: 700; padding: 6px; border-radius: 8px; color: #fff; letter-spacing: .05em; }
.mode-pill.test { background: var(--test); }
.mode-pill.real { background: var(--real); }
.mode-switch { font-size: 12px; text-align: center; }
nav { display: grid; gap: 2px; margin-top: 4px; }
nav a { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; border-radius: 8px; color: var(--text); }
nav a:hover { background: var(--panel-2); text-decoration: none; }
nav a.active { background: var(--accent); color: #fff; }
nav .sep { height: 1px; background: var(--line); margin: 6px 4px; }
.badge { display: inline-block; min-width: 20px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--panel-2); border: 1px solid var(--line); text-align: center; }
nav a.active .badge { background: rgba(255,255,255,.25); border-color: transparent; color: #fff; }
.logout { margin-top: auto; }
main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 5; }
.top-right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.menu { display: none; }
.view { padding: 20px 22px 60px; display: grid; gap: 16px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: grid; gap: 4px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: var(--panel-2); font-weight: 600; font-size: 12.5px; color: var(--muted); white-space: nowrap; cursor: default; }
th.sortable { cursor: pointer; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
tr.clickable { cursor: pointer; }
td.actions { white-space: nowrap; text-align: right; }
tr.rejected td { text-decoration: line-through; color: var(--muted); }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* tags */
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.pending { background: var(--warn-bg); color: var(--warn); }
.tag.accepted, .tag.on, .tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.cancelled, .tag.rejected, .tag.off, .tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.info { background: var(--info-bg); color: var(--info); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-right: 6px; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }

/* forms */
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--info); outline-offset: -1px; }
textarea { min-height: 120px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 7px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.form { display: grid; gap: 12px; }
.form .fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.form label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.form .full { grid-column: 1 / -1; }
.form .check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.form .check input { width: auto; }
.switch { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--line); border: none; cursor: pointer; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { left: 23px; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--panel); border-radius: 14px; width: 100%; max-width: 720px; max-height: 90vh; overflow: auto; padding: 18px; border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 10px; max-width: 360px; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }
.token-box { background: var(--panel-2); border: 1px dashed var(--accent); padding: 12px; border-radius: 10px; word-break: break-all; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
pre.json { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; max-height: 160px; overflow: auto; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .menu { display: inline-block; }
  .g2, .g4, .form .fields { grid-template-columns: 1fr; }
  .view { padding: 14px 16px 60px; }
  .top { padding: 12px 16px; }
  .toolbar input, .toolbar select { min-width: 0; width: 100%; }
}

/* jar faylının yeri: 📁 qovluq\ + fayl adı, bir sətirdə; uzundursa sondan qısalır */
.pathbox { display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); min-width: 0; }
.pathbox .ico { font-size: 18px; line-height: 1; flex: none; }
.pathbox .p { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.pathbox .p span { direction: ltr; unicode-bidi: embed; }
.pathbox .p .fn { font-weight: 600; }
.pathbox .dir { color: var(--muted); }
.pathbox .fn { font-weight: 600; color: var(--text); }
.pathbox .btn { flex: none; }
