/* Tridi Takip – internal panel styles */
:root {
  --font: 'Satoshi', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --navy: #1F3A5F;
  --navy-700: #16304f;
  --navy-100: #e6edf5;
  --ink: #16202b;
  --ink-2: #4a5765;
  --ink-3: #7b8794;
  --line: #dfe5ec;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ok: #1f7a4d;   --ok-bg: #e3f3ea;
  --warn: #9a6400; --warn-bg: #fff2d6;
  --bad: #b3261e;  --bad-bg: #fde7e5;
  --mute-bg: #eef1f4;
  --info: #2b5d9f; --info-bg: #e4eefb;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --shadow: 0 1px 2px rgba(22,32,43,.06), 0 8px 24px -12px rgba(22,32,43,.18);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 14px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
a { color: var(--navy); }
button { font: inherit; }
.num { font-variant-numeric: tabular-nums lining-nums; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--navy); color: #fff; padding: 8px 12px; border-radius: var(--r-sm); z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Gate */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: var(--navy); color: #fff; }
.gate-card { width: min(420px, 100%); background: var(--surface); color: var(--ink); border-radius: var(--r-lg); padding: 28px 24px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--navy); }
.brand .mark { width: 28px; height: 28px; }
.brand.small { font-weight: 700; font-size: 15px; }
.brand.small .mark { width: 22px; height: 22px; }
.gate .brand { margin-bottom: 20px; }
.gate-brand { flex-direction: column; align-items: flex-start; gap: 14px; }
.gate-brand .logo { width: 200px; height: auto; display: block; }
.gate-brand h1 { font-size: 15px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; margin: 0; padding-top: 12px; border-top: 1px solid var(--line); width: 100%; }
.brand.small .mark { width: 22px; height: auto; }
.gate-foot { margin: 20px 0 0; font-size: 12px; color: var(--ink-3); }
.gate p { color: var(--ink-2); margin: 0 0 16px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 8px 0 18px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--navy); display: block; }
.pin-dots i.on { background: var(--navy); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pin-pad button { height: 56px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); font-size: 20px; font-weight: 500; color: var(--ink); cursor: pointer; }
.pin-pad button:active { background: var(--navy-100); }
.pin-pad button.ghost { border-color: transparent; font-size: 14px; color: var(--ink-2); }
.gate-error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 0 0 8px; text-align: center; }
.gate-link { background: none; border: 0; color: var(--navy); text-decoration: underline; cursor: pointer; padding: 0; font-size: 13px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 500; text-decoration: none; }
.btn:hover { background: var(--mute-bg); }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-700); }
.btn.danger { color: var(--bad); border-color: #f0c7c4; }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { width: 40px; height: 40px; display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: var(--r-sm); color: inherit; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: rgba(255,255,255,.12); }
.sheet-head .icon-btn:hover { background: var(--mute-bg); }

/* Topbar */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 56px; background: var(--navy); color: #fff; }
.topbar .brand { color: #fff; }
.tabs { display: none; gap: 4px; margin-left: 8px; }
.tabs a { color: rgba(255,255,255,.78); text-decoration: none; padding: 8px 12px; border-radius: var(--r-sm); font-weight: 500; }
.tabs a.active { color: #fff; background: rgba(255,255,255,.14); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 4px; position: relative; }
.sync { font-size: 12px; color: rgba(255,255,255,.75); margin-right: 6px; white-space: nowrap; }
.sync.offline { color: #ffd37a; }
.menu { position: absolute; right: 0; top: 46px; background: var(--surface); color: var(--ink); border-radius: var(--r-md); box-shadow: var(--shadow); min-width: 220px; padding: 6px; z-index: 30; }
.menu-user { font-size: 12px; color: var(--ink-3); padding: 8px 10px 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; word-break: break-all; }
.menu button { display: block; width: 100%; text-align: left; padding: 10px; border: 0; background: none; border-radius: var(--r-sm); cursor: pointer; color: var(--ink); }
.menu button:hover { background: var(--mute-bg); }

/* Main */
.main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px calc(72px + var(--safe-b)); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-head h1 { font-size: 18px; }
.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; }
.card h3 { margin-bottom: 10px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.kpi .v { font-size: 22px; font-weight: 700; line-height: 1.1; }
.kpi .v.money { font-size: 18px; white-space: nowrap; }
@media (min-width: 760px) { .kpi .v.money { font-size: 20px; } }
.kpi .l { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.kpi.warn .v { color: var(--warn); } .kpi.bad .v { color: var(--bad); } .kpi.ok .v { color: var(--ok); }
.quota { display: grid; gap: 10px; }
.quota-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.quota-row .bar { grid-column: 1 / -1; height: 8px; border-radius: 4px; background: var(--mute-bg); overflow: hidden; }
.quota-row .bar i { display: block; height: 100%; background: var(--navy); }
.quota-row .bar i.warn { background: var(--warn); } .quota-row .bar i.bad { background: var(--bad); }
.quota-row .n { font-size: 13px; color: var(--ink-2); }

/* Lists */
.list { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 12px 14px; border-top: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; width: 100%; font: inherit; }
.row:first-child { border-top: 0; }
.row:hover { background: #f8fafc; }
.row .t { font-weight: 500; grid-column: 1; grid-row: 1; }
.row .s { font-size: 12.5px; color: var(--ink-2); grid-column: 1; grid-row: 2; }
.row .r { grid-column: 2; grid-row: 1 / span 2; align-self: center; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row .r .d { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.empty { padding: 20px 14px; color: var(--ink-3); text-align: center; font-size: 14px; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--mute-bg); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.mute { background: var(--mute-bg); color: var(--ink-3); }

/* Filters */
.toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.search { position: relative; }
.search input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 0 12px 0 38px; font: inherit; background: var(--surface); }
.search svg { position: absolute; left: 12px; top: 13px; width: 18px; height: 18px; color: var(--ink-3); }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
select.chip { appearance: none; -webkit-appearance: none; padding-right: 26px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='%234a5765' stroke-width='2'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 14px; }
.count { font-size: 12.5px; color: var(--ink-3); }

/* Detail */
.dl { display: grid; grid-template-columns: 1fr; gap: 0; }
.dl > div { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.dl > div:first-child { border-top: 0; }
.dl dt { color: var(--ink-2); margin: 0; } .dl dd { margin: 0; word-break: break-word; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0; }
.actions .btn.block { grid-column: 1 / -1; }
.section { margin-top: 18px; }
.section h3 { margin-bottom: 8px; }
.mini { font-size: 13px; color: var(--ink-2); }
.hist { display: grid; gap: 6px; font-size: 13.5px; }
.hist div { display: grid; grid-template-columns: 90px 1fr auto; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.hist div:first-child { border-top: 0; }

/* Forms */
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.form input, .form select, .form textarea { height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 0 12px; font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); width: 100%; }
.form textarea { height: auto; min-height: 72px; padding: 10px 12px; resize: vertical; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .hint { font-size: 12px; color: var(--ink-3); }
.form .check { display: flex; align-items: center; gap: 10px; flex-direction: row; min-height: 44px; }
.form .check input { width: 20px; height: 20px; }
.form .calc { background: var(--navy-100); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13.5px; color: var(--navy); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.form-actions .btn { flex: 1; }
.err { color: var(--bad); font-size: 13px; }

/* Sheet (slide-over) */
.sheet { position: fixed; inset: 0; z-index: 40; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(22,32,43,.45); }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92dvh; background: var(--surface); border-radius: 16px 16px 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 10px 18px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 16px; padding-right: 8px; }
.sheet-body { overflow-y: auto; overscroll-behavior: contain; padding: 14px 18px calc(18px + var(--safe-b)); }

/* Bottom tabs */
.bottom-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.bottom-tabs a { display: grid; justify-items: center; gap: 2px; padding: 8px 0 6px; font-size: 11px; font-weight: 500; color: var(--ink-3); text-decoration: none; min-height: 52px; }
.bottom-tabs a svg { width: 22px; height: 22px; }
.bottom-tabs a.active { color: var(--navy); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(76px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 60; box-shadow: var(--shadow); max-width: 90vw; }
.toast.bad { background: var(--bad); }

/* Skeleton */
.skel { background: linear-gradient(90deg, #eef1f4 25%, #f6f8fa 50%, #eef1f4 75%); background-size: 200% 100%; animation: sh 1.2s infinite; border-radius: var(--r-sm); height: 14px; }
@keyframes sh { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel, .sheet-panel { animation: none; } }

/* Desktop */
@media (min-width: 760px) {
  .tabs { display: flex; }
  .bottom-tabs { display: none; }
  .main { padding: 24px 24px 40px; }
  .grid.two { grid-template-columns: 1fr 1fr; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .toolbar { flex-direction: row; align-items: center; }
  .search { flex: 1; max-width: 420px; }
  .sheet-panel { left: auto; right: 0; top: 0; bottom: 0; width: min(560px, 100%); max-height: none; border-radius: 0; animation: in .22s ease-out; }
  @keyframes in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
  .toast { bottom: 24px; }
  .dl > div { grid-template-columns: 170px 1fr; }
}
