:root {
  --bg: #e8e1d6;
  --card: #fcfaf6;
  --ink: #2b2723;
  --muted: #8a8377;
  --line: #dbd2c4;
  --accent: #2b2723;
  --accent-ink: #f6f1e9;
  --accent-soft: #ddd3c4;
  --danger: #b3402a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
  --tap: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px calc(14px) 18px;
  padding-top: calc(14px + env(safe-area-inset-top));
  background: rgba(232,225,214,.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: .5px; font-size: 20px; }
.broker-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--ink); cursor: pointer;
}
.broker-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 120px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 18px;
}
.title { font-size: 22px; margin: 2px 0 18px; }

.field { display: block; margin-bottom: 18px; }
.label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .4px; }
.muted { color: var(--muted); font-weight: 500; text-transform: none; letter-spacing: 0; }

input[type=text], input[type=tel], input[type=email], input[type=date],
input[type=datetime-local], textarea, .select {
  width: 100%; min-height: var(--tap);
  border: 1.5px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 17px; font-family: inherit; color: var(--ink);
  background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, .select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%237a7d77' stroke-width='2'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 42px; }

.with-action { display: flex; gap: 8px; }
.with-action input { flex: 1; }
.mini-btn { min-width: var(--tap); height: var(--tap); border: 1.5px solid var(--line); background: #fff; border-radius: 12px; font-size: 22px; cursor: pointer; }

/* Segmented */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.segmented.wrap-cols { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }
.seg {
  min-height: var(--tap); border: 1.5px solid var(--line); background: #fff;
  border-radius: 12px; font-size: 15px; font-weight: 600; color: var(--ink);
  cursor: pointer; padding: 8px; display: flex; align-items: center; justify-content: center; text-align: center;
}
.seg[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* Combo (paieška) */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px;
  max-height: 280px; overflow-y: auto; box-shadow: var(--shadow);
}
.combo-item { padding: 13px 14px; font-size: 16px; cursor: pointer; border-bottom: 1px solid var(--line); }
.combo-item:last-child { border-bottom: none; }
.combo-item:hover, .combo-item.active { background: var(--accent-soft); }
.chosen { margin-top: 8px; display: inline-flex; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; padding: 8px 12px; border-radius: 999px; font-size: 14px; }
.chosen button { border: none; background: none; color: var(--accent); font-size: 18px; cursor: pointer; line-height: 1; }

.checkrow { display: flex; align-items: center; gap: 12px; min-height: var(--tap); font-weight: 600; }
.checkrow input { width: 24px; height: 24px; accent-color: var(--accent); }

.more { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 4px; margin-bottom: 18px; }
.more summary { cursor: pointer; font-weight: 700; color: var(--accent); padding: 12px 0; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary::after { content: " ▾"; }
.more[open] summary::after { content: " ▴"; }

.paste-box { background: var(--accent-soft); border-radius: 14px; padding: 12px; margin-bottom: 20px; }
.paste-box textarea { background: #fff; min-height: 56px; }
.ghost-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 46px; margin-top: 10px;
  border: 1.5px solid var(--accent); background: #fff; color: var(--accent);
  border-radius: 12px; font-size: 15px; font-weight: 700; cursor: pointer;
}
.ghost-btn:disabled { opacity: .6; }
.ghost-btn svg { width: 18px; height: 18px; }
.paste-box .muted { margin-top: 8px; font-size: 13px; display: block; }

.primary {
  width: 100%; min-height: 56px; border: none; border-radius: 14px;
  background: var(--accent); color: var(--accent-ink); font-size: 18px; font-weight: 700;
  cursor: pointer; box-shadow: var(--shadow);
}
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .6; }

/* Banner */
.banner { padding: 14px 16px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.banner.info { background: var(--accent-soft); color: var(--accent); }
.banner.error { background: #fbe9e5; color: var(--danger); }

/* Success */
.success { text-align: center; }
.check { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 34px; display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; }
.success h2 { margin: 4px 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0; }
.action {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink); font-weight: 600; font-size: 14px;
  text-decoration: none; cursor: pointer; padding: 8px;
}
.action:active { background: var(--accent-soft); }
.action svg { width: 18px; height: 18px; flex: 0 0 auto; }
.mini-btn svg { width: 22px; height: 22px; }
.mini-btn { display: flex; align-items: center; justify-content: center; }
.install { display: inline-flex; align-items: center; gap: 8px; }
.install svg { width: 18px; height: 18px; }

/* Tabai */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 5px; box-shadow: var(--shadow); }
.tab { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: none; background: transparent; border-radius: 10px; font-size: 15px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tab svg { width: 18px; height: 18px; }
.tab[aria-pressed=true] { background: var(--accent); color: var(--accent-ink); }

/* Paskutiniai */
.recent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.recent-head .title { margin: 0; }
#recentStatus { margin-bottom: 12px; }
.rc { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: #fff; }
.rc-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px; border: none; background: transparent; text-align: left; cursor: pointer; }
.rc-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rc-name { font-weight: 700; font-size: 16px; }
.rc-sub { font-size: 13px; color: var(--muted); }
.rc-status { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 4px 10px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
.rc-body { padding: 0 14px 14px; }
.rc-info { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; }
.rc-line { font-size: 14px; padding: 2px 0; }
.rc-comment { color: var(--muted); }
.rc-cal { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.rc-dt { width: 100%; margin: 8px 0; }

/* Install */
.install {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 30;
  background: var(--ink); color: #fff; border: none; border-radius: 999px;
  padding: 14px 22px; font-size: 15px; font-weight: 700; box-shadow: var(--shadow); cursor: pointer;
}

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(20,20,18,.45); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal-card {
  background: #fff; width: 100%; max-width: 560px; border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); box-shadow: var(--shadow);
  max-height: 85vh; display: flex; flex-direction: column;
}
.modal-card h2 { margin: 0 0 4px; }
.modal-card input { margin: 12px 0; }
.broker-list { overflow-y: auto; }
.broker-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 8px;
  border-bottom: 1px solid var(--line); cursor: pointer; font-size: 17px; font-weight: 600;
}
.broker-row .avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.ios-share { font-size: 18px; }

#pinInput { text-align: center; letter-spacing: 8px; font-size: 22px; font-weight: 700; }
.login-error { color: var(--danger); font-weight: 600; margin: 4px 0 12px; }
#loginModal .primary { margin-top: 12px; }

@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 20px; }
}
