/* ============================================================
   Qurious SMS Gateway — UI
   A calm, dense operations console. Indigo/slate, one amber
   accent reserved for the thing that matters: credits & cost.
   ============================================================ */

:root {
    --bg:        #0f1729;   /* deep slate-navy app background */
    --surface:   #ffffff;
    --surface-2: #f5f7fb;
    --ink:       #16203a;   /* primary text */
    --ink-soft:  #5b6b8c;   /* secondary text */
    --line:      #e2e8f4;   /* hairline borders */
    --indigo:    #3d4ee6;   /* primary action */
    --indigo-d:  #2c3ac9;
    --amber:     #d98a2b;   /* cost / credits accent */
    --amber-bg:  #fdf4e7;
    --green:     #12805c;
    --green-bg:  #e6f4ee;
    --red:       #c0392b;
    --red-bg:    #fbeceb;
    --radius:    10px;
    --radius-s:  7px;
    --shadow:    0 1px 2px rgba(16,23,41,.06), 0 6px 20px rgba(16,23,41,.06);
    --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    font-family: var(--sans);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--indigo); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top bar ------------------------------------------------ */
.topbar {
    background: var(--bg);
    border-bottom: 1px solid rgba(255,255,255,.08);
    position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
    max-width: 1180px; margin: 0 auto;
    display: flex; align-items: center; gap: 28px;
    padding: 0 22px; height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--indigo), #6b78ff);
    color: #fff; font-weight: 800; font-size: 16px;
    display: grid; place-items: center;
}
.brand-name { font-weight: 600; letter-spacing: .2px; color: #eef1fb; }
.brand-name em { font-style: normal; color: #9aa6d4; font-weight: 500; }

.mainnav { display: flex; gap: 4px; margin-left: 8px; }
.mainnav a {
    color: #aab4d8; padding: 7px 13px; border-radius: 7px;
    font-size: 14px; font-weight: 500;
}
.mainnav a:hover { color: #fff; background: rgba(255,255,255,.06); text-decoration: none; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 18px; }
.balance-pill {
    display: flex; flex-direction: column; align-items: flex-end;
    line-height: 1.1; padding: 6px 12px; border-radius: 8px;
    background: rgba(217,138,43,.14); border: 1px solid rgba(217,138,43,.3);
}
.balance-pill:hover { text-decoration: none; background: rgba(217,138,43,.2); }
.balance-label { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: #e0b57e; }
.balance-value { font-size: 16px; font-weight: 700; color: #f6d9ab; font-variant-numeric: tabular-nums; }

.usermenu { display: flex; align-items: center; gap: 12px; }
.user-name { color: #dfe4f5; font-size: 14px; font-weight: 500; }
.logout { color: #8b96bd; font-size: 13px; }
.logout:hover { color: #fff; }

/* ---- Page shell -------------------------------------------- */
.page {
    max-width: 1180px; margin: 26px auto; padding: 0 22px 60px;
}
.pagefoot {
    max-width: 1180px; margin: 0 auto; padding: 20px 22px 40px;
    color: #6b779c; font-size: 12.5px; display: flex; gap: 10px; align-items: center;
}
.pagefoot .dot { color: #3a4560; opacity: .5; }

/* ---- Page heading ------------------------------------------ */
.pagehead { margin: 4px 0 22px; }
.pagehead h1 { margin: 0 0 4px; font-size: 24px; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.pagehead p { margin: 0; color: #9aa6d0; font-size: 14px; }

/* ---- Cards ------------------------------------------------- */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 22px;
}
.card + .card { margin-top: 18px; }
.card h2 {
    margin: 0 0 4px; font-size: 16px; font-weight: 650; color: var(--ink);
}
.card .card-sub { margin: 0 0 18px; color: var(--ink-soft); font-size: 13.5px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-compose { grid-template-columns: 1.35fr 1fr; align-items: start; }

@media (max-width: 900px) {
    .grid-2, .grid-3, .grid-4, .grid-compose { grid-template-columns: 1fr; }
    .mainnav { display: none; }
}

/* ---- Stat tiles -------------------------------------------- */
.stat {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); margin-bottom: 8px; }
.stat .v { font-size: 28px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat.accent .v { color: var(--amber); }
.stat .meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; }

/* ---- Forms ------------------------------------------------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.hint { font-weight: 400; color: var(--ink-soft); font-size: 12.5px; }

input[type=text], input[type=password], input[type=number], textarea, select {
    width: 100%; padding: 10px 12px; font-size: 14.5px; font-family: inherit;
    color: var(--ink); background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius-s);
    transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, textarea:focus, select:focus {
    outline: none; border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(61,78,230,.13);
}
.field + .field { margin-top: 16px; }
.recipients-box { min-height: 150px; font-family: var(--mono); font-size: 13.5px; }
.message-box { min-height: 130px; }

/* ---- Buttons ----------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; font-size: 14.5px; font-weight: 600; font-family: inherit;
    border: 1px solid transparent; border-radius: var(--radius-s);
    cursor: pointer; transition: background .12s, transform .04s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--indigo); color: #fff; }
.btn-primary:hover { background: var(--indigo-d); text-decoration: none; }
.btn-primary:disabled { background: #b7bdf0; cursor: not-allowed; }
.btn-ghost { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #eceff7; text-decoration: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { padding: 13px 22px; font-size: 15.5px; }

/* ---- Compose meter ----------------------------------------- */
.meter {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: var(--radius-s); padding: 16px 18px;
}
.meter-row { display: flex; justify-content: space-between; align-items: baseline; padding: 7px 0; }
.meter-row + .meter-row { border-top: 1px dashed var(--line); }
.meter-row .m-k { color: var(--ink-soft); font-size: 13px; }
.meter-row .m-v { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 15px; }
.meter-row.cost { margin-top: 4px; }
.meter-row.cost .m-v { color: var(--amber); font-size: 19px; }
.meter-row.balance-after .m-v.negative { color: var(--red); }
.enc-badge {
    display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .4px;
    padding: 2px 8px; border-radius: 20px; background: var(--surface-2);
    border: 1px solid var(--line); color: var(--ink-soft);
}
.enc-badge.unicode { background: var(--amber-bg); border-color: #f0d6ac; color: var(--amber); }

/* ---- Preview phone ----------------------------------------- */
.preview {
    background: #0d1424; border-radius: 16px; padding: 18px; margin-top: 14px;
}
.preview .bubble {
    background: #e9edf6; color: #14203a; border-radius: 14px 14px 14px 4px;
    padding: 10px 13px; font-size: 14px; line-height: 1.5; max-width: 85%;
    white-space: pre-wrap; word-break: break-word;
}
.preview .sender { color: #8fa0c9; font-size: 11px; margin-bottom: 6px; letter-spacing: .3px; }
.preview .bubble.empty { color: #9aa6c4; font-style: italic; background: #1a2438; }

/* ---- Recipient validation chips ---------------------------- */
.recipient-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
}
.chip.ok   { background: var(--green-bg); color: var(--green); }
.chip.bad  { background: var(--red-bg);   color: var(--red); }
.chip.dup  { background: var(--amber-bg); color: var(--amber); }
.chip .n { font-variant-numeric: tabular-nums; }
.invalid-list {
    margin-top: 10px; font-family: var(--mono); font-size: 12.5px;
    color: var(--red); max-height: 90px; overflow-y: auto;
    background: var(--red-bg); border-radius: 6px; padding: 8px 10px;
}

/* ---- Tables ------------------------------------------------ */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { padding: 11px 14px; text-align: left; font-size: 13.5px; }
table.data thead th {
    background: var(--surface-2); color: var(--ink-soft);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data tbody tr { border-top: 1px solid var(--line); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.mono { font-family: var(--mono); font-size: 12.5px; }
.tag {
    display: inline-block; padding: 2px 9px; border-radius: 20px;
    font-size: 11.5px; font-weight: 700;
}
.tag.accepted { background: var(--green-bg); color: var(--green); }
.tag.failed   { background: var(--red-bg);   color: var(--red); }
.tag.processing { background: #e8eefc; color: var(--indigo-d); }
.tag.completed { background: var(--green-bg); color: var(--green); }
.tag.completed_with_errors { background: var(--amber-bg); color: var(--amber); }
.tag.queued { background: var(--surface-2); color: var(--ink-soft); }
.tag.paused { background: var(--amber-bg); color: var(--amber); }
.tag.cancelled { background: var(--red-bg); color: var(--red); }
.tag.sent { background: var(--green-bg); color: var(--green); }
.tag.sending { background: #e8eefc; color: var(--indigo-d); }

/* ---- Progress bar ------------------------------------------ */
.progress-outer {
    background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 20px; height: 16px; overflow: hidden; margin: 6px 0 10px;
}
.progress-inner {
    height: 100%; background: linear-gradient(90deg, var(--indigo), #6b78ff);
    border-radius: 20px; transition: width .6s ease; min-width: 2px;
}
.progress-label {
    display: flex; justify-content: space-between; font-size: 13.5px;
    color: var(--ink-soft); font-variant-numeric: tabular-nums;
}
.progress-label strong { color: var(--ink); }
code {
    font-family: var(--mono); font-size: 12.5px; background: rgba(0,0,0,.06);
    padding: 1px 6px; border-radius: 4px;
}

/* ---- Flash messages ---------------------------------------- */
.flash {
    padding: 12px 16px; border-radius: var(--radius-s); margin-bottom: 16px;
    font-size: 14px; font-weight: 500; border: 1px solid transparent;
}
.flash-success { background: var(--green-bg); color: var(--green); border-color: #bfe3d3; }
.flash-error   { background: var(--red-bg);   color: var(--red);   border-color: #f2cdc9; }
.flash-info    { background: #e8eefc; color: var(--indigo-d); border-color: #cdd8fa; }
.flash-warning { background: var(--amber-bg); color: var(--amber); border-color: #f0d6ac; }

/* ---- Login ------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.4); padding: 34px 30px;
}
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-card .brand-name { color: var(--ink); }
.login-card .brand-name em { color: var(--ink-soft); }
.login-title { text-align: center; color: var(--ink-soft); font-size: 13.5px; margin: 0 0 24px; }

/* ---- Utility ----------------------------------------------- */
.muted { color: var(--ink-soft); }
.mono { font-family: var(--mono); }
.right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.nowrap { white-space: nowrap; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state .big { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.section-actions { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.pagination { display: flex; gap: 6px; margin-top: 18px; justify-content: center; }
.pagination a, .pagination span {
    padding: 6px 12px; border-radius: 6px; font-size: 13px;
    border: 1px solid rgba(255,255,255,.12); color: #c3cbe6;
}
.pagination .current { background: var(--indigo); color: #fff; border-color: var(--indigo); }
