:root {
    --bg-deep: #030712;
    --bg: #0f1c2d;
    --bg-alt: #16263b;
    --surface: rgba(16, 30, 48, 0.92);
    --card: rgba(20, 36, 57, 0.92);
    --primary: #fbbf24;
    --primary-dark: #f97316;
    --secondary: #ff5400;
    --accent: #1dd3b0;
    --text: #f8fbff;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --danger: #ff4d6d;
    --success: #4ade80;
    --shadow: 0 25px 80px rgba(3, 7, 18, 0.7);
}

* {
    box-sizing: border-box;
}

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

body {
    font-family: 'Inter', 'Space Grotesk', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(circle at top, rgba(255, 185, 0, 0.15), transparent 45%),
        radial-gradient(circle at 18% 20%, rgba(13, 148, 136, 0.18), transparent 40%),
        var(--bg-deep);
    color: var(--text);
    height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url('data:image/svg+xml,%3Csvg width="200" height="200" xmlns="http://www.w3.org/2000/svg"%3E%3Cpath d="M0 120 Q60 80 120 120 T240 120" fill="none" stroke="rgba(255,255,255,0.03)" stroke-width="2"/%3E%3C/svg%3E');
    opacity: 0.9;
    pointer-events: none;
    z-index: 0;
}

.app-shell {
    position: relative;
    z-index: 1;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.page {
    width: 100%;
    padding: clamp(12px, 2vw, 24px);
}

.page-landing {
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2vw, 24px);
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: clamp(8px, 1.5vw, 12px);
}

.brand-badge {
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #0f172a;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.brand h1 {
    margin: 0;
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    letter-spacing: 0.06em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.btn-outline {
    border-radius: 14px;
    padding: 10px 18px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
}

.ws-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: clamp(0.65rem, 1.8vw, 0.85rem);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text);
    max-width: min(230px, 70vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.ws-pill.online {
    background: rgba(74, 222, 128, 0.12);
    border-color: rgba(74, 222, 128, 0.4);
    color: var(--success);
}

.ws-heartbeat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.heartbeat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 rgba(29, 211, 176, 0.4);
    animation: heartbeatDot 1.6s ease-in-out infinite;
}

.heartbeat-wave {
    width: 28px;
    height: 12px;
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 12"%3E%3Cpolyline points="0,6 4,6 7,2 10,10 13,6 20,6 23,2 26,10 29,6 32,6" fill="none" stroke="%231dd3b0" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/%3E%3C/svg%3E');
    background-size: cover;
    opacity: 0.75;
    animation: heartbeatTrace 1.6s linear infinite;
}

.ws-pill:not(.online) .heartbeat-dot,
.ws-pill:not(.online) .heartbeat-wave {
    animation-play-state: paused;
    opacity: 0.35;
    box-shadow: none;
}

.ws-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes heartbeatDot {
    0%,
    100% {
        transform: scale(0.9);
        box-shadow: 0 0 0 rgba(29, 211, 176, 0.15);
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 12px rgba(29, 211, 176, 0.55);
    }
}

@keyframes heartbeatTrace {
    0% {
        transform: translateX(0);
        opacity: 0.35;
    }
    25% {
        opacity: 0.65;
    }
    100% {
        transform: translateX(-4px);
        opacity: 0.35;
    }
}

.hero-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: clamp(16px, 2vw, 32px);
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    min-height: 0;
}

.hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(10px, 1.5vw, 16px);
    align-items: flex-start;
    text-align: left;
}

.hero-copy h2 {
    font-size: clamp(2rem, 3.5vw, 3.2rem);
    margin: 0 0 clamp(8px, 1vw, 12px);
    line-height: 1.05;
}

.hero-copy p {
    color: var(--text-muted);
    font-size: clamp(0.95rem, 1.5vw, 1.05rem);
    max-width: 520px;
    margin: 0 0 clamp(12px, 1.5vw, 16px);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.35em;
    font-size: clamp(0.7rem, 1.2vw, 0.8rem);
    color: var(--accent);
    margin-bottom: clamp(6px, 1vw, 10px);
}

.landing-flow-card {
    background: var(--surface);
    border-radius: 28px;
    padding: clamp(16px, 2.5vw, 24px);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 1.5vw, 16px);
    max-width: 420px;
    align-items: center;
    text-align: center;
    width: 100%;
}

.landing-flow-status {
    display: flex;
    justify-content: center;
    align-items: center;
}

.landing-flow-card .ghost-button,
.landing-flow-card .result,
.landing-flow-card .landing-profile,
.landing-step {
    width: 100%;
}

.landing-step {
    align-items: center;
}

.landing-step {
    display: none;
    flex-direction: column;
    gap: clamp(8px, 1vw, 12px);
}

.landing-step.active {
    display: flex;
}

label {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: center;
    width: 100%;
    display: block;
    word-break: normal;
    white-space: normal;
    box-sizing: border-box;
}

.input-field {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: clamp(12px, 1.5vw, 16px);
    background: rgba(255, 255, 255, 0.02);
    box-sizing: border-box;
    color: var(--text);
    font-size: clamp(1.1rem, 2vw, 1.35rem);
    letter-spacing: 0.2em;
    text-align: center;
}

.input-field:focus {
    outline: 2px solid var(--primary);
    border-color: transparent;
}

.input-field.input-error {
    border-color: rgba(248, 113, 113, 0.9);
    box-shadow:
        0 0 0 1px rgba(248, 113, 113, 0.7),
        0 0 16px rgba(248, 113, 113, 0.45);
    animation: input-shake 0.16s ease-in-out 2;
}

@keyframes input-shake {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-4px);
    }
    50% {
        transform: translateX(4px);
    }
    75% {
        transform: translateX(-2px);
    }
    100% {
        transform: translateX(0);
    }
}

.landing-profile {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    display: none;
}

.landing-profile.visible {
    display: block;
}

.landing-profile h4 {
    margin: 0 0 6px;
}

.hero-device {
    position: relative;
    perspective: 1100px;
}

.device-shell {
    width: min(420px, 90vw);
    margin: 0 auto;
    aspect-ratio: 3 / 5.8;
    border-radius: 42px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 40px 120px rgba(0, 0, 0, 0.55);
    transform: rotateX(6deg) rotateY(-12deg);
    padding: 26px;
    overflow: hidden;
}

.device-screen {
    width: 100%;
    height: 100%;
    border-radius: 32px;
    background: linear-gradient(200deg, rgba(12, 21, 36, 0.95), rgba(8, 14, 26, 0.98));
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.device-metric {
    border-radius: 18px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
}

.feature-row {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

#deviceFeatures {
    margin-top: auto;
}

.feature-card {
    border-radius: 16px;
    padding: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

.feature-card h3 {
    margin: 0 0 4px;
    font-size: 0.95rem;
}

.feature-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.page-dashboard {
    background: var(--bg-alt);
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
    padding: clamp(12px, 2vw, 24px) 0;
    overflow: hidden;
}

.dashboard-container {
    width: min(1200px, 100%);
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: clamp(16px, 2vw, 24px);
    align-items: center;
    margin: 0 auto;
    padding: 0 clamp(16px, 4vw, 32px);
    box-sizing: border-box;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.dashboard-header {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: clamp(12px, 1.5vw, 20px);
    flex-shrink: 0;
}

.dashboard-header-top {
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(12px, 3vw, 32px);
    flex-wrap: wrap;
    box-sizing: border-box;
}

.dashboard-identity {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(10px, 2vw, 20px);
    text-align: left;
    flex: 1 1 auto;
    min-width: 0;
    box-sizing: border-box;
}

.dashboard-title-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    text-align: left;
    min-width: 0;
}

.dashboard-title {
    margin: 0;
    font-size: clamp(1.2rem, 4.5vw, 2rem);
    letter-spacing: 0.05em;
    line-height: 1.1;
}

.dashboard-greeting {
    margin: 0;
    font-size: clamp(0.78rem, 3.6vw, 0.95rem);
    color: var(--text-muted);
    white-space: nowrap;
}

.dashboard-pill {
    border-radius: 999px;
    padding: 10px clamp(14px, 3.5vw, 26px);
    background: linear-gradient(120deg, var(--secondary), var(--primary));
    color: #0f172a;
    border: 1px solid transparent;
    font-weight: 600;
    box-shadow: 0 18px 40px rgba(251, 191, 36, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button.dashboard-pill {
    cursor: pointer;
}

button.dashboard-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 22px 48px rgba(251, 191, 36, 0.32);
}

button.dashboard-pill:active {
    transform: translateY(0);
    box-shadow: 0 12px 28px rgba(251, 191, 36, 0.2);
    opacity: 0.9;
}

.dashboard-logo-pill {
    font-size: clamp(0.9rem, 2.2vw, 1rem);
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-weight: 700;
    pointer-events: none;
}

#logoutBtn {
    flex: 0 0 auto;
    min-width: clamp(110px, 18vw, 150px);
    white-space: nowrap;
}

@media (max-width: 520px) {
    .dashboard-header-top {
        gap: clamp(8px, 2vw, 16px);
    }

    .dashboard-logo-pill {
        padding: 8px 16px;
        font-size: clamp(0.75rem, 4vw, 0.9rem);
        letter-spacing: 0.12em;
    }

    .dashboard-title {
        letter-spacing: 0.03em;
    }

    .dashboard-greeting {
        font-size: clamp(0.72rem, 3.2vw, 0.85rem);
    }

    #logoutBtn {
        padding: 8px 18px;
    }
}

.dashboard-header .header-actions {
    justify-content: center;
}

.dashboard-stats-row {
    width: 100%;
    display: flex;
    gap: clamp(8px, 2vw, 18px);
    align-items: stretch;
    justify-content: center;
    flex-wrap: nowrap;
}

.dashboard-stat {
    flex: 1 1 0;
    border-radius: 18px;
    padding: clamp(12px, 2vw, 18px);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    text-align: left;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.dashboard-stat h4 {
    margin: 0 0 4px;
    font-size: clamp(0.7rem, 2vw, 0.85rem);
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.dashboard-stat .value {
    font-size: clamp(1.1rem, 3vw, 1.9rem);
    font-weight: 600;
    white-space: nowrap;
}

.dashboard-body {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.side-nav {
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(6px, 1.5vw, 12px);
    padding: clamp(6px, 1.5vw, 12px);
    border-radius: 18px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
    box-sizing: border-box;
}

.side-nav button {
    flex: 1 1 0;
    min-width: 0;
    padding: clamp(8px, 1.5vw, 12px) clamp(10px, 2vw, 18px);
    border-radius: 12px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text);
    font-weight: 600;
    font-size: clamp(0.72rem, 2.4vw, 0.95rem);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
}

.side-nav button.active {
    border-color: rgba(251, 191, 36, 0.7);
    background: rgba(251, 191, 36, 0.12);
    color: var(--primary);
}

.panel-stack {
    border-radius: 24px;
    border: 1px solid var(--border);
    background: rgba(4, 10, 20, 0.55);
    padding: clamp(16px, 2vw, 32px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(16px, 2vw, 24px);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

.panel-stack > * {
    width: min(100%, 640px);
    max-width: 100%;
    box-sizing: border-box;
}

.panel {
    display: none;
    flex-direction: column;
    gap: 16px;
    min-height: 0;
    width: 100%;
    max-width: 100%;
}

.panel.active {
    display: flex;
}

.panel,
.form-card {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    text-align: center;
}

.form-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    border: 1px solid var(--border);
    padding: 20px;
    background: rgba(255, 255, 255, 0.02);
}

.form-card .input-group,
.form-card label,
.form-card button {
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-sizing: border-box;
}

.form-state-input,
.form-state-loading,
.form-state-result {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    box-sizing: border-box;
}

.form-state-loading {
    padding: 40px 20px;
}

.form-state-result {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.form-state-input.hidden,
.form-state-loading.hidden,
.form-state-result.hidden {
    display: none;
}

.result-card {
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(15, 23, 42, 0.9);
    padding: clamp(12px, 2vw, 18px) clamp(14px, 2.5vw, 18px);
    margin-top: clamp(8px, 1.5vw, 12px);
    margin-bottom: clamp(8px, 1.5vw, 12px);
    text-align: center;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 600px;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
    overflow: hidden;
}

.result-card button {
    width: auto;
    min-width: 120px;
    max-width: 100%;
    box-sizing: border-box;
}

.result-card p,
.result-card .kv-value,
.result-card .kv-label,
.result-card h4 {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

.result-card.success {
    border-color: rgba(34, 197, 94, 0.7);
}

.result-card.error {
    border-color: rgba(248, 113, 113, 0.8);
    background: rgba(127, 29, 29, 0.5);
}

.result-card h4 {
    margin: 0 0 8px;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    text-align: center;
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
    gap: clamp(8px, 1.5vw, 10px) clamp(12px, 2vw, 18px);
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.kv-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
    text-align: center;
}

.kv-label {
    font-size: clamp(0.7rem, 1.8vw, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.kv-value {
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

.field-message {
    margin-top: 6px;
    min-height: 18px;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: clamp(0.7rem, 1.8vw, 0.75rem);
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.status-pill.success {
    border-color: rgba(34, 197, 94, 0.7);
    background: rgba(22, 163, 74, 0.1);
    color: var(--success);
}

.status-pill.error {
    border-color: rgba(248, 113, 113, 0.7);
    background: rgba(127, 29, 29, 0.5);
    color: var(--danger);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
}

.result-table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
    border-collapse: collapse;
    margin-top: 10px;
    margin-left: auto;
    margin-right: auto;
    font-size: 0.8rem;
    box-sizing: border-box;
}

/* Ensure table cells don't force fixed widths */
.result-table td {
    white-space: nowrap;
}

.history-table-wrapper {
    max-height: calc(100vh - 500px);
    min-height: 150px;
    overflow-y: auto;
    overflow-x: hidden;
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 8px;
}

/* Prevent horizontal overflow in tables */
.history-table-wrapper table {
    width: 100%;
    table-layout: fixed;
}

/* Fix code blocks and API keys section overflow */
pre,
code {
    max-width: 100%;
    overflow-x: auto;
    overflow-wrap: break-word;
    word-wrap: break-word;
    box-sizing: border-box;
}

pre {
    background: rgba(15, 23, 42, 0.9);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Account section and API keys container */
.account-section {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.account-section > * {
    max-width: 100%;
    box-sizing: border-box;
}

/* Ensure input fields in account section don't overflow */
.account-section input,
.account-section textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.result-table thead {
    background: rgba(15, 23, 42, 0.9);
}

.result-table th,
.result-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    text-align: left;
    white-space: nowrap;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Set column widths to prevent overflow */
/* First column (KES/Lookup) - dynamic width based on content */
.result-table th:nth-child(1),
.result-table td:nth-child(1) {
    width: auto;
    min-width: 60px;
    white-space: nowrap;
    padding-right: 8px;
    overflow: visible;
    text-overflow: clip;
}

/* Status column - compact, centered */
.result-table th:nth-child(2),
.result-table td:nth-child(2) {
    width: auto;
    min-width: 70px;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
}

/* Receipt/Reason column - centered */
.result-table th:nth-child(3),
.result-table td:nth-child(3) {
    width: auto;
    min-width: 100px;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Time column - centered */
.result-table th:nth-child(4),
.result-table td:nth-child(4) {
    width: auto;
    min-width: 120px;
    padding-left: 8px;
    padding-right: 8px;
    text-align: center;
    word-break: break-word;
    overflow-wrap: break-word;
}

.result-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

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

/* Status badge styling */
.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

.status-badge.status-success {
    background: rgba(34, 197, 94, 0.2);
    color: rgba(34, 197, 94, 1);
    border: 1px solid rgba(34, 197, 94, 0.4);
}

.status-badge.status-error {
    background: rgba(248, 113, 113, 0.2);
    color: rgba(248, 113, 113, 1);
    border: 1px solid rgba(248, 113, 113, 0.4);
}

.btn-primary,
.btn-outline,
.ghost-button {
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    border: none;
}

.btn-primary {
    padding: 14px;
    background: linear-gradient(120deg, var(--secondary), var(--primary));
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.ghost-button {
    background: none;
    color: var(--primary);
    padding: 0;
}

.openapi-docs-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: clamp(12px, 1.5vw, 14px) clamp(24px, 3vw, 28px);
    border-radius: 14px;
    border: 1px solid var(--primary);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-weight: 600;
    font-size: clamp(0.9rem, 1.3vw, 1rem);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: fit-content;
    text-align: center;
    margin-top: clamp(16px, 2vw, 24px);
    align-self: center;
    animation: apiButtonGlow 2s ease-in-out infinite;
}

.openapi-docs-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    animation: apiButtonGlow 1.5s ease-in-out infinite;
}

.openapi-docs-button:active {
    transform: translateY(0);
}

.openapi-docs-button svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.openapi-docs-button span {
    line-height: 1;
}

@keyframes apiButtonGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(251, 191, 36, 0.3),
                    0 0 20px rgba(251, 191, 36, 0.2),
                    0 0 30px rgba(251, 191, 36, 0.1);
        border-color: rgba(251, 191, 36, 0.6);
    }
    50% {
        box-shadow: 0 0 20px rgba(251, 191, 36, 0.6),
                    0 0 30px rgba(251, 191, 36, 0.4),
                    0 0 40px rgba(251, 191, 36, 0.3);
        border-color: rgba(251, 191, 36, 0.9);
    }
}

.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(6px);
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none !important;
}

@media (max-width: 960px) {
    .panel-stack > * {
        width: 100%;
    }
}

/* Account and section styles */
.account-section,
.vehicle-section,
.kra-pin-section,
.national-id-section {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.account-section {
    text-align: center;
}

.info-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
}

/* Ensure all form elements are properly constrained */
.form-card .input-group,
.form-card label,
.form-card button,
.form-card h3,
.form-card p {
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.form-card h3 {
    text-align: center;
    margin: 0 0 16px;
    width: 100%;
}

.form-card p {
    text-align: center;
    margin: 0;
}

@media (max-width: 720px) {
    .input-field {
        letter-spacing: 0.18em;
        font-size: 1.05rem;
    }

    .hero-copy {
        align-items: center;
        text-align: center;
    }

    .hero-device {
        display: none;
    }

    .feature-row {
        display: none;
    }
}

/* Hide full label, show only value on small screens */
@media (max-width: 520px) {
    .history-label-full {
        display: none;
    }
    
    .history-label-compact {
        display: inline;
    }
}

/* Show full label, hide compact value on larger screens */
@media (min-width: 521px) {
    .history-label-full {
        display: inline;
    }
    
    .history-label-compact {
        display: none;
    }
}

/* Optimize for smallest screens */
@media (max-width: 360px) {
    .result-table th,
    .result-table td {
        padding: 4px 6px;
        font-size: 0.6rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .result-table th {
        font-size: 0.55rem;
        letter-spacing: 0.05em;
    }

    .result-table td {
        font-size: 0.6rem;
    }

    /* Reduce column min-widths on smallest screens */
    .result-table th:nth-child(1),
    .result-table td:nth-child(1) {
        min-width: 50px;
        padding-right: 4px;
    }

    .result-table th:nth-child(2),
    .result-table td:nth-child(2) {
        min-width: 60px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .result-table th:nth-child(3),
    .result-table td:nth-child(3) {
        min-width: 80px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .result-table th:nth-child(4),
    .result-table td:nth-child(4) {
        min-width: 90px;
        padding-left: 4px;
        padding-right: 4px;
    }

    .status-badge {
        padding: 2px 5px;
        font-size: 0.55rem;
        letter-spacing: 0.02em;
    }

    .side-nav button {
        padding: 6px 8px;
        font-size: clamp(0.65rem, 2vw, 0.85rem);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .dashboard-title {
        font-size: clamp(1rem, 4vw, 1.5rem);
    }

    .dashboard-greeting {
        font-size: clamp(0.7rem, 3vw, 0.85rem);
    }

    .dashboard-stat {
        padding: clamp(10px, 1.5vw, 14px);
    }

    .dashboard-stat h4 {
        font-size: clamp(0.65rem, 1.8vw, 0.75rem);
    }

    .dashboard-stat .value {
        font-size: clamp(0.95rem, 2.5vw, 1.5rem);
    }

    .form-card {
        padding: 14px;
    }

    .panel-stack {
        padding: clamp(12px, 1.5vw, 24px);
        gap: 16px;
    }

    .result-card {
        padding: clamp(10px, 1.5vw, 14px) clamp(12px, 2vw, 14px);
        max-width: 100%;
    }

    .result-card h4 {
        font-size: clamp(0.8rem, 1.8vw, 0.85rem);
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .kv-label {
        font-size: clamp(0.65rem, 1.6vw, 0.7rem);
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .kv-value {
        font-size: clamp(0.8rem, 1.8vw, 0.85rem);
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}
