:root {
  --bg: #0b1020;
  --bg-2: #111731;
  --card: #151c37;
  --card-2: #1b2444;
  --line: #263159;
  --text: #f1f4fd;
  --muted: #b6c0dd;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: radial-gradient(1200px 700px at 85% -10%, #1c2a5c 0%, transparent 60%), var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.tiny {
  font-size: 11.5px;
}

.strong {
  font-weight: 600;
}

.nowrap {
  white-space: nowrap;
}

.spacer {
  flex: 1;
}

.lead {
  margin: 0;
  font-size: 12.8px;
  line-height: 1.9;
}

.ok-text {
  color: #86efac;
}
.warn-text {
  color: #fcd34d;
}

.divider {
  border-top: 1px solid var(--line);
  margin: 10px 0;
}

a {
  color: var(--accent-2);
}

.link {
  cursor: pointer;
  color: var(--accent-2);
}

h4 {
  margin: 4px 0 8px;
  font-size: 14px;
}

/* --------------------------------------------------------- bidi safety --
   Latin identifiers, numbers, dates and links must not be reordered by the
   bidi algorithm when they sit inside Persian text. <bdi> isolates each value,
   and .ltr forces genuinely left-to-right content (links, hosts, addresses)
   without dragging the surrounding layout with it.                          */

bdi {
  unicode-bidi: isolate;
}

.ltr {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
}

/* A labelled "a of b" pair. The separator is a real word, and each side is
   isolated, so the two numbers can never swap places. */
.ratio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.ratio .sep {
  color: var(--muted);
  font-size: 11.5px;
}

/* Success / failure counts. Colour and icon carry the meaning, so the reading
   direction of the page is irrelevant. */
.okfail {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.okfail .pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
}

.okfail .pill i {
  font-style: normal;
  font-size: 11px;
}

.okfail .pill.ok {
  background: color-mix(in srgb, var(--ok) 16%, transparent);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  color: #86efac;
}

.okfail .pill.bad {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  border-color: color-mix(in srgb, var(--danger) 38%, transparent);
  color: #fca5a5;
}

.okfail .rate {
  font-size: 11.5px;
  color: var(--muted);
}
.okfail .rate.good {
  color: #86efac;
}
.okfail .rate.mid {
  color: #fcd34d;
}
.okfail .rate.poor {
  color: #fca5a5;
}

/* ------------------------------------------------------------ login -- */

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 26px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 6px;
}

.login-card h1 {
  margin: 0;
  font-size: 21px;
  text-align: center;
}

.login-card > p {
  margin: 0 0 14px;
  text-align: center;
  font-size: 13px;
}

.login-card label {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 8px;
}

/* ------------------------------------------------------------ shell -- */

.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-2);
  border-inline-end: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--line);
}

#nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  color: var(--muted);
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 14px;
  background: none;
  text-align: start;
  width: 100%;
  font-family: inherit;
}

.nav-icon {
  width: 18px;
  text-align: center;
  opacity: 0.85;
}

.nav-label {
  flex: 1;
  text-align: start;
}

.nav-item:hover {
  background: var(--card);
  color: var(--text);
}

.nav-item.active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  color: #fff;
}

.badge {
  background: var(--danger);
  color: #fff;
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  line-height: 18px;
  font-weight: 700;
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.portal-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.portal-links a {
  text-align: center;
  text-decoration: none;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 16, 32, 0.7);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h2 {
  margin: 0;
  font-size: 17px;
}

#admin-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.4;
  background: none;
  border: none;
  padding: 0;
}

#admin-chip .who {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

#admin-chip .role {
  font-size: 11px;
  color: var(--muted);
}

.view {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ------------------------------------------------------------ parts -- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}

.card h3 {
  margin: 0 0 14px;
  font-size: 15px;
}

.grid {
  display: grid;
  gap: 14px;
}

.stats {
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}

.stats.compact {
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
}

.stat .label {
  color: var(--muted);
  font-size: 12.5px;
}

.stat .value {
  font-size: 23px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.02em;
}

.stat.ok .value {
  color: var(--ok);
}
.stat.warn .value {
  color: var(--warn);
}
.stat.danger .value {
  color: var(--danger);
}

.two-col {
  grid-template-columns: 1.4fr 1fr;
}

@media (max-width: 1000px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* -------- alerts -------- */

.alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: start;
  border-radius: 12px;
  padding: 11px 15px;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.alert .go {
  color: var(--muted);
}

/* The arrow points toward the section, whichever way the page reads. */
html[dir='ltr'] .alert .go {
  transform: scaleX(-1);
}

.alert.warn {
  border-color: color-mix(in srgb, var(--warn) 45%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, var(--card));
}
.alert.danger {
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, var(--card));
}
.alert.info {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
}

.alert:hover {
  filter: brightness(1.15);
}

/* -------- inputs -------- */

input,
select,
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

textarea {
  min-height: 84px;
  resize: vertical;
  font-family: inherit;
}

input[type='checkbox'] {
  width: auto;
  accent-color: var(--accent);
}

input[type='color'] {
  padding: 3px;
  height: 38px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > span {
  font-size: 12.5px;
  color: var(--muted);
}

.field .hint {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
  opacity: 0.85;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.field-row > input[type='number'],
.field-row > input[type='text'] {
  width: auto;
  min-width: 120px;
  flex: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

@media (max-width: 620px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-error {
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  color: #fecaca;
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 13px;
  margin-top: 8px;
  grid-column: 1 / -1;
}

/* -------- buttons -------- */

.btn {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  padding: 9px 15px;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
  font-size: 13.5px;
  transition: filter 0.15s, transform 0.05s, background 0.15s;
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(1.15);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.danger {
  background: color-mix(in srgb, var(--danger) 20%, var(--card-2));
  border-color: color-mix(in srgb, var(--danger) 50%, transparent);
  color: #fecaca;
}

.btn.ok {
  background: color-mix(in srgb, var(--ok) 20%, var(--card-2));
  border-color: color-mix(in srgb, var(--ok) 50%, transparent);
  color: #bbf7d0;
}

.btn.ghost {
  background: transparent;
}

.btn.small {
  padding: 6px 11px;
  font-size: 12.5px;
}

.btn.block {
  width: 100%;
  margin-top: 10px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
}

.toolbar {
  display: flex;
  gap: 9px;
  align-items: center;
  flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
  width: auto;
  min-width: 150px;
}

.toolbar h4 {
  margin: 0;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  padding: 10px 0;
  z-index: 4;
}

/* -------- segmented control -------- */

.seg {
  display: inline-flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
}

.seg.wrap {
  flex-wrap: wrap;
}

.seg-btn {
  border: none;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.on {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: #fff;
}

.vertical-seg {
  display: flex;
  flex-wrap: wrap;
}

/* -------- table -------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}

.table-wrap.flat {
  border: none;
  background: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  white-space: nowrap;
}

thead th {
  background: var(--card-2);
  text-align: start;
  padding: 11px 13px;
  font-weight: 600;
  color: var(--muted);
  font-size: 12.5px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
}

tbody td {
  padding: 10px 13px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

.row-actions {
  display: flex;
  gap: 5px;
}

.usage-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------- chips & tags -------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  font-size: 12px;
  color: var(--muted);
}

.chip.tiny {
  padding: 1px 8px;
  font-size: 11px;
}

.chip.alt {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-2);
}

.chip.link {
  cursor: pointer;
  font-family: inherit;
}

.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip.toggle {
  cursor: pointer;
  font-family: inherit;
}

.chip.toggle.on {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  color: #fff;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 260px;
  white-space: normal;
}

.tag {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
}

.tag.tiny {
  font-size: 10.5px;
  padding: 1px 7px;
}

.tag.active {
  background: color-mix(in srgb, var(--ok) 18%, transparent);
  color: #86efac;
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
}
.tag.expired {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: #fca5a5;
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
}
.tag.exhausted {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: #fcd34d;
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
}
.tag.disabled {
  background: #2a3255;
  color: var(--muted);
  border-color: var(--line);
}
.tag.primary {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent-2);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.tag.backup {
  background: #2a3255;
  color: var(--muted);
  border-color: var(--line);
}

.bar {
  height: 6px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
  min-width: 90px;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}

.bar > i.warn {
  background: var(--warn);
}
.bar > i.danger {
  background: var(--danger);
}

.truncate {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: bottom;
}

/* -------- key/value & credentials -------- */

.kv {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 18px;
  margin-bottom: 14px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dashed color-mix(in srgb, var(--line) 70%, transparent);
  padding: 5px 0;
  font-size: 13px;
}

@media (max-width: 620px) {
  .kv {
    grid-template-columns: 1fr;
  }
}

.cred-box {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cred-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cred-line code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 15px;
  background: var(--card-2);
  border-radius: 8px;
  padding: 5px 10px;
  direction: ltr;
  text-align: left;
  user-select: all;
}

.receipt-view {
  text-align: center;
}

.receipt-view img {
  max-width: 100%;
  max-height: 62vh;
  border-radius: 12px;
  border: 1px solid var(--line);
  margin: 10px 0;
}

/* -------- permissions -------- */

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.perm-group {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}

.perm-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
  padding-bottom: 6px;
}

.perm-group-head h4 {
  margin: 0;
  flex: 1;
  font-size: 13px;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
  cursor: pointer;
}

.perm-item code {
  margin-inline-start: auto;
  font-size: 10.5px;
  opacity: 0.55;
  direction: ltr;
}

/* -------- tickets -------- */

.split {
  display: grid;
  grid-template-columns: 330px 1fr;
  gap: 14px;
  min-height: 66vh;
}

@media (max-width: 900px) {
  .split {
    grid-template-columns: 1fr;
  }
}

.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.ticket-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 62vh;
  overflow-y: auto;
}

.ticket-item {
  text-align: start;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ticket-item:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
}

.ticket-item.on {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--card));
}

.ticket-item.unread .ti-subject {
  font-weight: 700;
}

.ti-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ti-subject {
  flex: 1;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ti-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ticket-chat {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  min-height: 66vh;
  min-width: 0;
}

.chat-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.chat-head h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.chat-head select {
  width: auto;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 52vh;
}

.bubble {
  max-width: min(70%, 560px);
  border-radius: 14px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  background: var(--card-2);
  align-self: flex-start;
}

.bubble.admin {
  align-self: flex-end;
  background: color-mix(in srgb, var(--accent) 20%, var(--card-2));
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}

.bubble.system {
  align-self: center;
  background: transparent;
  border-style: dashed;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 85%;
  text-align: center;
}

.bubble-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 3px;
}

.bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13.5px;
}

.bubble-image img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  margin-top: 6px;
  display: block;
}

.chat-compose {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-compose textarea {
  min-height: 62px;
}

.compose-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* -------- settings -------- */

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* -------- modal -------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 16, 0.66);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  width: min(640px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
}

.modal.wide {
  width: min(960px, 100%);
}

.modal h3 {
  margin: 0 0 16px;
  font-size: 17px;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-actions {
  display: flex;
  gap: 9px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* -------- toasts -------- */

.toasts {
  position: fixed;
  inset-block-end: 20px;
  inset-inline-end: 20px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  z-index: 99;
}

.toast {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 15px;
  box-shadow: var(--shadow);
  max-width: 340px;
  animation: slide-in 0.18s ease-out;
  font-size: 13.5px;
}

.toast.ok {
  border-color: color-mix(in srgb, var(--ok) 55%, transparent);
}
.toast.err {
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* -------- chart --------
   Charts always read left to right: a time axis is not a sentence, and every
   Persian dashboard convention agrees. The container is forced to LTR so the
   oldest day sits on the left in both languages. */

.chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 150px;
  padding-top: 10px;
}

.chart.tall {
  height: 190px;
  gap: 3px;
}

.chart .col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 5px;
  height: 100%;
}

.chart .col > i {
  display: block;
  width: 100%;
  max-width: 42px;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-radius: 6px 6px 0 0;
  min-height: 3px;
}

.chart .col > small {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

/* -------- responsive -------- */

.only-mobile {
  display: none;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: 250px;
    z-index: 40;
    transform: translateX(var(--sb-hide, -110%));
    transition: transform 0.2s;
  }
  html[dir='rtl'] .sidebar {
    --sb-hide: 110%;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .only-mobile {
    display: inline-block;
  }
  .view {
    padding: 16px;
  }
  .bubble {
    max-width: 88%;
  }
}

/* ------------------------------------------------------------------ */
/* Renewal summary                                                     */
/* ------------------------------------------------------------------ */

/* What the renewal will actually do, worked out before the button is
   pressed: the money to collect, and the expiry, allowance and usage the
   account ends up with. Resellers get no manual controls, so this panel is
   the only place the numbers are visible to them. */
.renew-summary {
  background: var(--card-2, rgba(127, 127, 127, 0.08));
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.renew-total {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.renew-amount {
  margin-inline-start: auto;
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.renew-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
}

.renew-line .strong {
  margin-inline-start: auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.ok-text {
  color: var(--ok);
  font-weight: 700;
}
