/* EndoFinans · Saha Harcama Takibi — business application look (desktop program on PC, standard app on phone). */
:root {
  --bg: #eef0f2; --surface: #ffffff; --surface-2: #f6f7f8; --surface-3: #e9ecef; --text: #1d2125; --muted: #5f6870; --line: #d4d9de; --line-strong: #b9c0c7;
  --brand: #1e5f74; --brand-dark: #153f4d; --brand-soft: #e5eff3; --head: #1f2a33; --head-text: #e8edf1;
  --danger: #b3261e; --danger-soft: #fbeceb; --warn: #8a5a00; --warn-soft: #fff4dc; --ok: #22663c; --ok-soft: #e6f3ea;
  --r: 4px; --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 14px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.login-card .band { background: var(--head); color: var(--head-text); padding: 16px 20px; }
.login-card .inner { padding: 20px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; }
.logo img { width: 28px; height: 28px; }
.logo small { display: block; font-weight: 400; font-size: 12px; opacity: .75; }
.login h1 { font-size: 16px; margin: 0 0 14px; }

/* ---------- application frame ---------- */
.shell { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.appbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 12px; padding-top: env(safe-area-inset-top); background: var(--head); color: var(--head-text); }
.appbar .logo { font-size: 15px; }
.appbar .company { opacity: .7; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar .spacer { flex: 1; }
.appbar .user { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border: 0; background: none; color: inherit; cursor: pointer; border-radius: var(--r); font-size: 13px; }
.appbar .user:hover { background: rgba(255, 255, 255, .1); }
.appbar .user .name { display: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: #3c4c58; color: #fff; font-weight: 600; font-size: 12px; }
.body { display: grid; grid-template-columns: 1fr; min-height: 0; }
.sidebar { display: none; }
main.content { padding: 14px 12px 110px; min-width: 0; }
.statusbar { display: none; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; padding: 0 0 env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); }
.tabbar button { flex: 1; display: grid; justify-items: center; gap: 1px; padding: 8px 2px 7px; border: 0; background: none; color: var(--muted); font-size: 11px; cursor: pointer; border-top: 2px solid transparent; }
.tabbar button[aria-current="page"] { color: var(--brand); border-top-color: var(--brand); font-weight: 600; }
.fab { position: fixed; right: 16px; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 31; display: inline-flex; align-items: center; gap: 8px; padding: 13px 18px; border-radius: 16px; border: 0; background: var(--brand); color: #fff; font-weight: 600; font-size: 15px; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); cursor: pointer; }
.only-desktop { display: none !important; }
@media (min-width: 960px) {
  .appbar .user .name { display: inline; }
  .body { grid-template-columns: 210px 1fr; }
  .sidebar { display: block; background: var(--surface); border-right: 1px solid var(--line); padding: 8px 0; }
  .sidebar .group { padding: 10px 14px 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
  .sidebar button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 14px; border: 0; border-left: 3px solid transparent; background: none; color: var(--text); cursor: pointer; text-align: left; }
  .sidebar button:hover { background: var(--surface-2); }
  .sidebar button[aria-current="page"] { background: var(--brand-soft); border-left-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
  main.content { padding: 16px 20px 56px; }
  .statusbar span { padding: 0 14px; white-space: nowrap; }
  .statusbar span:first-child { padding-left: 0; }
  .statusbar span + span { border-left: 1px solid var(--line-strong); }
  .statusbar { display: flex; position: fixed; left: 210px; right: 0; bottom: 0; height: 28px; align-items: center; padding: 0 14px; background: var(--surface-3); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
  .statusbar b { color: var(--text); font-weight: 600; }
  .tabbar, .fab { display: none; }
  .only-desktop { display: inline-flex !important; }
  .only-phone { display: none !important; }
}

/* ---------- page ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px; }
.page-head h1 { margin: 0; font-size: 18px; font-weight: 600; flex: 1; min-width: 160px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
.panel + .panel { margin-top: 12px; }
.grid > .panel + .panel { margin-top: 0; }
.grid + .panel { margin-top: 12px; }
.lead { margin-top: 0; }
.mt { margin: 12px 0 0; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: 6px 6px 0 0; }
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; flex: 1; }
.panel-body { padding: 12px; }
.grid { display: grid; gap: 12px; }
.two { grid-template-columns: 1fr; }
@media (min-width: 900px) { .two { grid-template-columns: 1fr 1fr; } }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--line); border-radius: 6px; background: var(--surface); margin-bottom: 12px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: 10px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat small { display: block; color: var(--muted); font-size: 12px; }
.stat b { display: block; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (min-width: 760px) { .stat { border-bottom: 0; } .stat:last-child { border-right: 0; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: #9aa3ab; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.link { border-color: transparent; background: none; color: var(--brand); padding: 0 6px; height: 28px; }
.btn.link:hover { text-decoration: underline; background: none; }
.btn.block { width: 100%; height: 40px; }
@media (max-width: 959px) { .btn { height: 40px; } }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.field input, .field select, .field textarea { width: 100%; height: 36px; padding: 6px 9px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: 15px; }
.field textarea { height: auto; min-height: 70px; }
@media (max-width: 959px) { .field input, .field select { height: 42px; font-size: 16px; } }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.form-grid { display: grid; gap: 0 12px; }
@media (min-width: 560px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .span2 { grid-column: span 2; } }
.error { border: 1px solid #e4b4b0; background: var(--danger-soft); color: var(--danger); padding: 8px 10px; border-radius: var(--r); margin-bottom: 12px; }
.hint { color: var(--muted); font-size: 12.5px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.search { position: relative; flex: 1 1 240px; max-width: 420px; }
.search input { width: 100%; height: 34px; padding: 4px 9px 4px 32px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); font-size: 14px; }
@media (max-width: 959px) { .search { max-width: none; } .search input { height: 42px; font-size: 16px; } }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--muted); }
select.input { height: 34px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); padding: 0 8px; }
@media (max-width: 959px) { select.input { height: 42px; } }
.period { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--surface); max-width: 100%; overflow-x: auto; }
.period button { border: 0; border-right: 1px solid var(--line); background: none; padding: 0 10px; height: 32px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.period button:last-child { border-right: 0; }
.period button[aria-pressed="true"] { background: var(--brand); color: #fff; }
@media (max-width: 959px) { .period button { height: 38px; } }
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 9px; border-radius: var(--r); background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #c6dbe3; font-size: 13px; }
.tag button { border: 0; background: none; color: inherit; cursor: pointer; display: grid; place-items: center; width: 20px; height: 20px; }
.tag svg { width: 14px; height: 14px; }

/* data grid */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 7px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 7px 10px; border-bottom: 1px solid #e7eaed; vertical-align: middle; }
tbody tr:nth-child(even) td { background: #fafbfc; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--brand-soft); }
tfoot td { padding: 7px 10px; font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
td .row { flex-wrap: nowrap; }

/* phone list */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 12px; border: 0; border-bottom: 1px solid #e7eaed; background: none; width: 100%; text-align: left; cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:active { background: var(--brand-soft); }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { grid-column: 1; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .a { grid-row: 1 / span 2; grid-column: 2; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; align-self: center; }
.item .a .state { display: block; margin-top: 2px; }
.group-head { display: flex; justify-content: space-between; padding: 6px 2px; margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.only-wide { display: none; }
@media (min-width: 960px) { .only-wide { display: block; } th.only-wide, td.only-wide { display: table-cell; } .only-narrow { display: none; } }

.state { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 12px; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.state.done { background: var(--ok-soft); color: var(--ok); border-color: #c4e2cd; }
.state.partial, .state.pending, .state.processing { background: var(--warn-soft); color: var(--warn); border-color: #f0dba8; }
.state.failed, .state.not_receipt { background: var(--danger-soft); color: var(--danger); border-color: #efc7c3; }
.state.disabled, .state.off { background: var(--surface-3); color: var(--muted); }

.ranking td.bar-cell { width: 34%; }
.meter { height: 8px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--brand); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty h3 { margin: 0 0 4px; color: var(--text); font-size: 15px; }

/* dialogs */
dialog#modal { border: 1px solid var(--line-strong); padding: 0; background: var(--surface); color: var(--text); width: 100%; max-width: 100%; max-height: 94dvh; margin: auto auto 0; border-radius: 8px 8px 0 0; box-shadow: 0 8px 28px rgba(0, 0, 0, .28); }
dialog#modal::backdrop { background: rgba(20, 28, 34, .45); }
@media (min-width: 700px) { dialog#modal { width: min(600px, 92vw); margin: auto; border-radius: 6px; } dialog#modal.wide { width: min(1000px, 94vw); } }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.modal-head h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 14px 16px 16px; overflow-y: auto; max-height: calc(94dvh - 52px); }
.icon-btn { width: 32px; height: 32px; border-radius: var(--r); border: 0; background: none; color: var(--text); display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--line); }

.drop { display: grid; gap: 10px; justify-items: center; text-align: center; padding: 16px; border: 1px dashed var(--line-strong); border-radius: 6px; background: var(--surface-2); margin-bottom: 12px; }
.preview { max-height: 240px; max-width: 100%; border: 1px solid var(--line); }
.receipt-view { display: grid; gap: 14px; }
@media (min-width: 860px) { .receipt-view { grid-template-columns: 1fr 1.15fr; align-items: start; } }
.receipt-img { width: 100%; max-height: 38dvh; object-fit: contain; background: var(--surface-3); border: 1px solid var(--line); }
@media (min-width: 860px) { .receipt-img { max-height: 72dvh; } }
.actions { display: grid; gap: 8px; }
.actions .btn { justify-content: flex-start; }
.props { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 13.5px; }
.props th { width: 38%; text-align: left; font-weight: 400; color: var(--muted); padding: 5px 8px 5px 0; border-bottom: 1px solid #edf0f2; vertical-align: top; background: none; position: static; }
.props td { padding: 5px 0; border-bottom: 1px solid #edf0f2; font-weight: 600; overflow-wrap: anywhere; background: none !important; }
.notice { padding: 8px 10px; border-radius: var(--r); border: 1px solid #f0dba8; background: var(--warn-soft); color: var(--warn); font-size: 13px; margin-bottom: 12px; }
.notice.ok { border-color: #c4e2cd; background: var(--ok-soft); color: var(--ok); }
.notice.bad { border-color: #efc7c3; background: var(--danger-soft); color: var(--danger); }

.suggest { position: relative; }
.suggest ul { position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% - 10px); margin: 0; padding: 2px 0; list-style: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: 0 4px 12px rgba(0, 0, 0, .12); max-height: 220px; overflow-y: auto; }
.suggest li button { width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.suggest li button:hover, .suggest li button:focus { background: var(--brand-soft); }
.suggest li small { color: var(--muted); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; padding: 14px; color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%); opacity: 0; pointer-events: none; z-index: 60; background: #263238; color: #fff; padding: 9px 14px; border-radius: var(--r); max-width: calc(100vw - 32px); transition: opacity .15s; font-size: 13.5px; }
@media (min-width: 960px) { #toast { bottom: 44px; } }
#toast.show { opacity: 1; }
.menu { position: fixed; right: 10px; top: 50px; z-index: 40; min-width: 220px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); box-shadow: 0 6px 18px rgba(0, 0, 0, .18); padding: 4px 0; }
.menu .who { padding: 8px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu .who small { display: block; color: var(--muted); }
.menu button { width: 100%; text-align: left; padding: 8px 12px; border: 0; background: none; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.menu button:hover { background: var(--surface-2); }
