:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --ink: #16202b;
    --muted: #6b7a89;
    --line: #d9e0e7;
    --gold: #b8860b;
    --green: #1c7c4a;
    --red: #b3261e;
    --blue: #1f5c8b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", "Tahoma", "Arial", sans-serif;
    font-size: 18px;
    line-height: 1.8;
}

header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 14px 24px;
    background: var(--ink);
    color: #fff;
}

.brand { font-size: 26px; font-weight: 700; color: var(--gold); }

header nav a {
    color: #fff;
    text-decoration: none;
    margin-left: 8px;
    padding: 6px 16px;
    border-radius: 8px;
}

header nav a:hover { background: #223245; }
header nav a.on { background: var(--gold); color: #fff; }

main { padding: 20px 24px 40px; max-width: 1180px; margin: 0 auto; }

h1 { font-size: 28px; margin: 0 0 6px; }

.sub { color: var(--muted); margin: 0 0 18px; }

.teller-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.teller-head h1 { margin: 0; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 22px;
}

.card h2 { font-size: 21px; margin: 0 0 14px; }

table { width: 100%; border-collapse: collapse; }

th, td { padding: 12px 10px; text-align: right; border-bottom: 1px solid var(--line); }

th { color: var(--muted); font-weight: 600; font-size: 16px; }

td.num { font-variant-numeric: tabular-nums; font-weight: 600; }

.tag {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 15px;
    background: #eef2f6;
    color: var(--muted);
}

.tag.isolated { background: #fdeceb; color: var(--red); }
.tag.liquid { background: #e8f5ee; color: var(--green); }

button, .btn {
    font-family: inherit;
    font-size: 20px;
    padding: 14px 28px;
    min-height: 56px;
    border: 0;
    border-radius: 10px;
    background: var(--gold);
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:disabled { background: #b9c3cc; cursor: not-allowed; }

/* ───────────────────────── الشباك ───────────────────────── */

.row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }

.fld { display: flex; flex-direction: column; gap: 4px; min-width: 190px; }
.fld.grow { flex: 1; }
.fld label { color: var(--muted); font-size: 15px; }

input, select {
    font-family: inherit;
    font-size: 19px;
    padding: 10px 12px;
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

input:focus, select:focus { outline: 3px solid #cfe0ee; border-color: var(--blue); }

.big-input { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

.hint { color: var(--muted); font-size: 14px; min-height: 20px; }
.hint-bad { color: var(--red); font-weight: 600; }

.dir { display: flex; gap: 12px; margin-bottom: 16px; }

.dir-opt {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 62px;
    border: 2px solid var(--line);
    border-radius: 10px;
    font-size: 21px;
    font-weight: 700;
    cursor: pointer;
    background: #fbfcfd;
}

.dir-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.dir-opt.buy:has(input:checked) { border-color: var(--green); background: #e8f5ee; color: var(--green); }
.dir-opt.sell:has(input:checked) { border-color: var(--blue); background: #e7f0f7; color: var(--blue); }

.grades { display: flex; gap: 8px; }

.grade-opt {
    min-height: 52px;
    padding: 0 18px;
    display: flex;
    align-items: center;
    border: 2px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    background: #fbfcfd;
    font-size: 18px;
}

.grade-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.grade-opt:has(input:checked) { border-color: var(--gold); background: #fdf6e6; font-weight: 700; }

.equiv {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 16px 20px;
    border-radius: 10px;
    background: #eef2f6;
    margin: 6px 0 12px;
}

.equiv.is-buy { background: #e8f5ee; }
.equiv.is-sell { background: #e7f0f7; }
.equiv-label { font-size: 19px; color: var(--muted); }
.equiv-value { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; }
.equiv-cur { font-size: 19px; color: var(--muted); }

.warn { margin-bottom: 12px; }
.warn:empty { display: none; }
.warn div { padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; font-size: 17px; }
.warn-soft div { background: #fdf6e6; color: #7a5c04; }
.warn-block div { background: #fdeceb; color: var(--red); font-weight: 600; }

.denoms { border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; margin-bottom: 14px; }
.denoms summary { cursor: pointer; color: var(--muted); font-size: 16px; }
.denom-grid { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 0 4px; }
.denom { display: flex; flex-direction: column; gap: 2px; width: 118px; }
.denom label { color: var(--muted); font-size: 14px; }
.denom input { min-height: 46px; font-size: 18px; }
.denom-sum { font-size: 16px; min-height: 22px; }
.denom-sum.ok { color: var(--green); font-weight: 600; }
.denom-sum.bad { color: var(--red); font-weight: 600; }

.actions { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.btn-go { background: var(--green); min-width: 230px; font-size: 22px; font-weight: 700; }
.btn-print { background: var(--ink); }
.approve { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--muted); }
.approve input { min-height: 44px; width: 160px; font-size: 18px; }

.row-void td { color: var(--muted); text-decoration: line-through; }
.row-void td.tiny { text-decoration: none; }
td.tiny { font-size: 13px; color: var(--muted); word-break: break-word; max-width: 320px; }
.cancel-form { display: flex; gap: 6px; align-items: center; }
.cancel-form input { min-height: 38px; font-size: 14px; padding: 4px 8px; width: 120px; }
.cancel-form button { min-height: 38px; }
.keys { color: var(--muted); font-size: 15px; margin-right: auto; }

.alert { padding: 14px 18px; border-radius: 10px; margin-bottom: 18px; font-size: 18px; }
.alert-bad { background: #fdeceb; color: var(--red); border: 1px solid #f2c6c3; }
.alert-block { background: #fff4e0; color: #8a5200; border: 1px solid #f0d3a0; font-weight: 600; }
.alert-ok { background: #e8f5ee; color: #10502f; border: 1px solid #b9e0c9; }

.done-grid { display: flex; flex-wrap: wrap; gap: 10px 28px; margin-bottom: 12px; }
.done-grid > div { display: flex; flex-direction: column; line-height: 1.4; }
.done-grid .lbl { font-size: 14px; color: #4d7a62; }
.done-grid b { font-size: 20px; font-variant-numeric: tabular-nums; }
.done-grid b.big { font-size: 34px; }

/* ───────────────────────── الأسعار ───────────────────────── */

.edit-table input.cell {
    width: 150px;
    min-height: 48px;
    font-size: 20px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* ───────────────────── اليوم والجرد والخزنة ───────────────────── */

.tag.warnish { background: #fdf6e6; color: #7a5c04; }

.note { padding: 12px 16px; border-radius: 8px; margin-bottom: 8px; font-size: 17px; }
.note-severe { background: #fdeceb; color: var(--red); font-weight: 600; }
.note-soft { background: #fdf6e6; color: #7a5c04; }
.note-ok { background: #e8f5ee; color: #10502f; }
.note a { color: inherit; }

.boxpick { display: flex; gap: 12px; flex-wrap: wrap; }

.boxbtn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 62px;
    padding: 8px 22px;
    border: 2px solid var(--line);
    border-radius: 10px;
    background: #fbfcfd;
    color: var(--ink);
    text-decoration: none;
    font-size: 19px;
    font-weight: 700;
}

.boxbtn small { color: var(--muted); font-size: 14px; font-weight: 400; }
.boxbtn.on { border-color: var(--gold); background: #fdf6e6; }

.blind-banner {
    background: var(--ink);
    color: #fff;
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 18px;
    font-size: 18px;
}

.countblk h2 { display: flex; align-items: center; gap: 10px; }

.counted-line {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 8px;
    background: #eef2f6;
    margin-top: 10px;
    font-size: 18px;
}

.counted-line b { font-size: 30px; font-variant-numeric: tabular-nums; }
.counted-line .sheets { color: var(--muted); font-size: 15px; }
.counted-line .book { margin-right: auto; color: var(--blue); font-weight: 600; }

.btn-sm { font-size: 16px; padding: 8px 16px; min-height: 40px; }
.btn-dim { background: var(--muted); }

@media (max-width: 1100px) {
    .fld { min-width: 150px; }
    .equiv-value { font-size: 32px; }
    header nav a { padding: 6px 10px; margin-left: 2px; }
}

/* ───────────────── ختم الوقت — ولا رقم بلا وقته ───────────────── */

.freshness {
    background: #e9eef3;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 14px;
    padding: 6px 24px;
    text-align: left;
}

.stamp {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    background: #eef2f6;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.stamp.sm { font-size: 12px; padding: 2px 9px; background: rgba(255, 255, 255, .28); color: inherit; }

/* ───────────────── شاشة المالك — الموبايل أولاً ───────────────── */

.own-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.own-head h1 { font-size: 23px; line-height: 1.3; }
.own-head .sub { margin: 0; font-size: 15px; }

h2.sec {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 19px;
    margin: 26px 0 12px;
}

h2.sec .stamp.sm { background: #eef2f6; color: var(--muted); }

/* بطاقات الربح — الفصل بين المحقق وغير المحقق هو الفكرة، فيبين بالألوان والحجم */

.profit { display: grid; gap: 14px; margin-bottom: 8px; }

.pcard { border-radius: 14px; padding: 16px 18px; color: #fff; }
.pcard header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.pcard .pk { font-size: 17px; font-weight: 700; opacity: .95; }

.pcard .pnum {
    display: block;
    font-size: 40px;
    font-weight: 800;
    line-height: 1.15;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.5px;
}

.pcard .pcur { display: block; font-size: 14px; opacity: .85; margin-top: 2px; }

.pcard .pbits { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid rgba(255, 255, 255, .25); }
.pcard .pbits li { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; padding: 3px 0; }
.pcard .pbits b { font-variant-numeric: tabular-nums; }
.pcard .pbits b.ok { color: #d6f5e3; }
.pcard .pbits b.bad { color: #ffd7d4; }

.pcard.realized { background: linear-gradient(160deg, #1c7c4a, #14603a); }
.pcard.unreal { background: linear-gradient(160deg, #1f5c8b, #17466a); }
.pcard.unreal.down { background: linear-gradient(160deg, #a1521a, #7d3f14); }
.pcard.netp { background: linear-gradient(160deg, #2b3a4a, #16202b); }
.pcard.netp.down { background: linear-gradient(160deg, #8f2b24, #6c211b); }

/* بطاقة مركز عملة */

.poscard {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
}

.poscard > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.poscard .cur { font-size: 19px; font-weight: 700; }
.poscard .cur small { color: var(--muted); font-weight: 400; font-size: 14px; }
.poscard .mark { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.poscard .mark small { display: block; font-size: 12px; }

.posnum { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 12px; flex-wrap: wrap; }
.posnum b { font-size: 36px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.posnum span { color: var(--muted); font-size: 14px; }

.breakdown { list-style: none; margin: 0; padding: 0; }
.breakdown li { display: flex; justify-content: space-between; gap: 14px; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.breakdown li:last-child { border-bottom: 0; }
.breakdown b { font-variant-numeric: tabular-nums; font-weight: 700; }
.breakdown li.zero { color: var(--muted); }
.breakdown li.sum { border-top: 2px solid var(--line); border-bottom: 0; margin-top: 4px; padding-top: 9px; font-weight: 700; }
.breakdown li.good b { color: var(--green); }
.breakdown li.bad b { color: var(--red); }
.breakdown.val { margin-top: 12px; padding-top: 6px; border-top: 1px solid var(--line); }

/* السقف */

.ceil { margin-top: 12px; }
.ceilbar { height: 12px; border-radius: 999px; background: #e6ebf0; overflow: hidden; }
.ceilbar i { display: block; height: 100%; border-radius: 999px; background: var(--green); }
.ceil.near .ceilbar i { background: var(--gold); }
.ceil.over .ceilbar i { background: var(--red); }
.ceiltxt { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-top: 5px; }
.ceil.safe .ceiltxt b { color: var(--green); }
.ceil.near .ceiltxt b { color: #7a5c04; }
.ceil.over .ceiltxt b { color: var(--red); }

.isolated-card { border-color: #f2c6c3; background: #fffaf9; }
.isolated-note { margin: 6px 0 10px; color: var(--red); font-size: 14px; }
.total-card { border-color: var(--ink); }

.demo { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; background: #fdf6e6; border: 1px dashed var(--gold); border-radius: 12px; padding: 14px 16px; margin-bottom: 30px; }
.demo b { display: block; font-size: 17px; }
.demo small { color: var(--muted); font-size: 14px; }
.demo button { width: 100%; }

@media (min-width: 700px) {
    .profit { grid-template-columns: 1fr 1fr; }
    .pcard.netp { grid-column: 1 / -1; }
    .own-head h1 { font-size: 28px; }
    .demo button { width: auto; }
}

@media (min-width: 1000px) {
    .profit { grid-template-columns: repeat(3, 1fr); }
    .pcard.netp { grid-column: auto; }
}

/* ───────────────── الموبايل ───────────────── */

@media (max-width: 700px) {
    body { font-size: 17px; }
    header { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 14px; }
    header nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
    header nav a { margin-left: 0; flex: 0 0 auto; font-size: 16px; padding: 8px 12px; }
    .freshness { padding: 6px 14px; text-align: center; }
    main { padding: 14px 14px 32px; }
    .card, .poscard { padding: 13px 14px; }
    .pcard .pnum { font-size: 34px; }
    .posnum b { font-size: 30px; }
    .card table { display: block; overflow-x: auto; }
    .row { flex-direction: column; }
    .fld { min-width: 0; }
    button, .btn { width: 100%; }
    .actions button, .actions .btn { width: auto; flex: 1 1 auto; }
}

/* مفاتيح المراحل بلوحة الأدمن */
.stages-cell { min-width: 320px; }
.stages { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-bottom: 6px; }
.stages .chip {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 12px; padding: 3px 8px; border: 1px solid #ddd; border-radius: 999px; cursor: pointer;
}
.stages .chip input { margin: 0; }
.stages .chip:has(input:checked) { background: #eef7ee; border-color: #7bb37b; }
