:root {
    /* Accent Colors */
    --tg-accent: #2AABEE;
    --tg-accent-dark: #229ED9;
    --tg-accent-light: #64C4F1;

    /* Light Theme */
    --tg-bg: #FFFFFF;
    --tg-bg-secondary: #F4F4F5;
    --tg-bg-tertiary: #EFEFF3;
    --tg-card: #FFFFFF;
    --tg-text: #000000;
    --tg-text-secondary: #707579;
    --tg-text-tertiary: #A0A0A0;
    --tg-border: #E5E5EA;
    --tg-divider: #E5E5EA;

    /* Status Colors */
    --tg-success: #34C759;
    --tg-danger: #FF3B30;
    --tg-warning: #FF9500;

    /* Shadows */
    --tg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --tg-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --tg-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);

    /* Spacing */
    --tg-spacing-xs: 4px;
    --tg-spacing-sm: 8px;
    --tg-spacing-md: 12px;
    --tg-spacing-lg: 16px;
    --tg-spacing-xl: 20px;
    --tg-spacing-2xl: 24px;

    /* Border Radius */
    --tg-radius-sm: 8px;
    --tg-radius-md: 12px;
    --tg-radius-lg: 16px;
    --tg-radius-xl: 20px;

    /* Typography */
    --tg-font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', 'Roboto', system-ui, sans-serif;
    --tg-font-size-xs: 12px;
    --tg-font-size-sm: 14px;
    --tg-font-size-base: 16px;
    --tg-font-size-lg: 17px;
    --tg-font-size-xl: 20px;
    --tg-font-size-2xl: 24px;
    --tg-font-size-3xl: 28px;

    /* Transitions */
    --tg-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --tg-transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);

    /* Bottom Nav Height */
    --tg-bottom-nav-height: 64px;

    /* Safe Area */
    --tg-safe-area-top: env(safe-area-inset-top, 0);
    --tg-safe-area-bottom: env(safe-area-inset-bottom, 0);
}

/* Dark Theme */
[data-theme="dark"] {
    --tg-bg: #0E1621;
    --tg-bg-secondary: #17212B;
    --tg-bg-tertiary: #1F2A35;
    --tg-card: #17212B;
    --tg-text: #FFFFFF;
    --tg-text-secondary: #8A98A5;
    --tg-text-tertiary: #6D7883;
    --tg-border: #2B3742;
    --tg-divider: #2B3742;

    --tg-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --tg-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --tg-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--tg-font-family);
    font-size: var(--tg-font-size-base);
    line-height: 1.5;
    color: var(--tg-text);
    background: var(--tg-bg);
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    transition: background-color var(--tg-transition), color var(--tg-transition);
    /* Prevent text size adjustment on orientation change */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Improve touch scrolling */
    touch-action: pan-y;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.2;
}

a {
    color: var(--tg-accent);
    text-decoration: none;
    transition: opacity var(--tg-transition-fast);
}

a:active {
    opacity: 0.7;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.tg-content {
    min-height: calc(100vh - var(--tg-bottom-nav-height) - var(--tg-safe-area-bottom));
    padding-bottom: calc(var(--tg-bottom-nav-height) + var(--tg-safe-area-bottom) + var(--tg-spacing-lg));
}

.tg-page-content {
    padding: var(--tg-spacing-lg);
}

/* ============================================
   SECTIONS
   ============================================ */
.tg-section {
    margin-bottom: var(--tg-spacing-2xl);
}

.tg-section-header {
    margin-bottom: var(--tg-spacing-md);
}

.tg-section-title {
    font-size: var(--tg-font-size-xl);
    font-weight: 600;
    color: var(--tg-text);
}

.tg-section-subtitle {
    font-size: var(--tg-font-size-sm);
    color: var(--tg-text-secondary);
    margin-top: var(--tg-spacing-xs);
}

/* ============================================
   LIST
   ============================================ */
.tg-list {
    background: var(--tg-card);
    border-radius: var(--tg-radius-md);
    overflow: hidden;
}

.tg-list-item {
    display: flex;
    align-items: center;
    padding: var(--tg-spacing-lg);
    border-bottom: 1px solid var(--tg-border);
    transition: background-color var(--tg-transition-fast);
    cursor: pointer;
    position: relative;
}

.tg-list-item:last-child {
    border-bottom: none;
}

.tg-list-item:active {
    background: var(--tg-bg-secondary);
}

.tg-list-item-icon {
    margin-right: var(--tg-spacing-md);
    display: flex;
    align-items: center;
}

.tg-list-item-icon svg {
    height: 28px;
}

.tg-list-item-content {
    flex: 1;
    min-width: 0;
}

.tg-list-item-title {
    font-size: var(--tg-font-size-lg);
    color: var(--tg-text);
    line-height: normal;
    font-weight: 400;
}

.tg-list-item-label {
    font-size: var(--tg-font-size-sm);
    color: var(--tg-text-secondary);
    margin-bottom: var(--tg-spacing-xs);
}

.tg-list-item-value {
    font-size: var(--tg-font-size-base);
    color: var(--tg-text);
}

.tg-list-item-arrow {
    font-size: 24px;
    color: var(--tg-text-tertiary);
    margin-left: var(--tg-spacing-sm);
    flex-shrink: 0;
}

.tg-list-item-danger {
    color: var(--tg-danger);
}

.tg-list-item-danger .tg-list-item-title {
    color: var(--tg-danger);
}

/* ============================================
   INPUTS
   ============================================ */
.tg-input-wrapper {
    margin-bottom: var(--tg-spacing-lg);
}


.tg-label {
    display: block;
    font-size: var(--tg-font-size-sm);
    color: var(--tg-text-secondary);
    margin-bottom: var(--tg-spacing-sm);
    font-weight: 500;
}

.tg-input,
.tg-textarea {
    width: 100%;
    padding: var(--tg-spacing-md) var(--tg-spacing-lg);
    font-size: var(--tg-font-size-base);
    font-family: var(--tg-font-family);
    color: var(--tg-text);
    background: var(--tg-card);
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius-md);
    outline: none;
    transition: border-color var(--tg-transition), box-shadow var(--tg-transition);
    -webkit-appearance: none;
}

.tg-input:focus,
.tg-textarea:focus {
    border-color: var(--tg-accent);
    box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.1);
}

.tg-input::placeholder,
.tg-textarea::placeholder {
    color: var(--tg-text-tertiary);
}

.tg-input-hint {
    font-size: var(--tg-font-size-xs);
    color: var(--tg-text-secondary);
    margin-top: var(--tg-spacing-xs);
}

.tg-input-wrapper.error .tg-input {
    border-color: var(--tg-danger);
}

.tg-input-wrapper.success .tg-input {
    border-color: var(--tg-success);
}

/* ============================================
   BUTTONS
   ============================================ */
.tg-button {
    width: 100%;
    padding: var(--tg-spacing-md) var(--tg-spacing-2xl);
    font-size: var(--tg-font-size-lg);
    font-weight: 500;
    font-family: var(--tg-font-family);
    border: none;
    border-radius: var(--tg-radius-md);
    cursor: pointer;
    transition: all var(--tg-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--tg-spacing-sm);
    position: relative;
    overflow: hidden;
    -webkit-appearance: none;
    outline: none;
}

.tg-button:active {
    transform: scale(0.98);
}

.tg-button-primary {
    background: var(--tg-accent);
    color: #FFFFFF;
    box-shadow: var(--tg-shadow-sm);
}

.tg-button-primary:active {
    background: var(--tg-accent-dark);
}

.tg-button-secondary {
    background: var(--tg-bg-secondary);
    color: var(--tg-accent);
}

.tg-button-secondary:active {
    background: var(--tg-bg-tertiary);
}

.tg-button-danger {
    background: var(--tg-danger);
    color: #FFFFFF;
}

.tg-button-danger:active {
    background: #E62E24;
}

.tg-button-success {
    background: var(--tg-success);
    color: #FFFFFF;
}

.tg-button-success:active {
    background: #28c34f;
}

.tg-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.tg-button.loading .button-text {
    display: none;
}

.tg-button.loading .button-loader {
    display: block;
}

.button-loader {
    display: none;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ============================================
   SKELETON LOADING (TELEGRAM STYLE)
   ============================================ */
.skeleton {
    background: linear-gradient(90deg,
            var(--tg-bg-secondary) 0%,
            var(--tg-bg-tertiary) 50%,
            var(--tg-bg-secondary) 100%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    border-radius: 6px;
    margin-bottom: 12px;
    width: 60%;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */
.tg-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background: var(--tg-card);
    border-top: 1px solid var(--tg-border);
    padding-bottom: var(--tg-safe-area-bottom);
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.tg-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--tg-spacing-sm) 0;
    color: var(--tg-text-tertiary);
    transition: color var(--tg-transition-fast);
    min-height: var(--tg-bottom-nav-height);
}

.tg-nav-item.active {
    color: var(--tg-accent);
}

.tg-nav-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--tg-spacing-xs);
}

.tg-nav-icon svg {
    width: 24px;
    height: 24px;
}

.tg-nav-icon-primary {
    background: var(--tg-accent);
    color: #FFFFFF;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    margin-top: -16px;
    box-shadow: var(--tg-shadow);
}

.tg-nav-icon-primary svg {
    width: 28px;
    height: 28px;
}

.tg-nav-label {
    font-size: var(--tg-font-size-xs);
    font-weight: 500;
}

/* ============================================
   MODALS & BOTTOM SHEETS
   ============================================ */
.tg-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.tg-modal.active {
    display: flex;
}

.tg-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    animation: fadeIn var(--tg-transition);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.tg-bottom-sheet {
    position: relative;
    width: 100%;
    max-width: 600px;
    background: var(--tg-card);
    border-radius: var(--tg-radius-xl) var(--tg-radius-xl) 0 0;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--tg-shadow-lg);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tg-modal.closing .tg-bottom-sheet {
    animation: slideDown 0.25s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

@keyframes slideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }

    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

.tg-modal.closing .tg-modal-backdrop {
    animation: fadeOut 0.25s ease-out forwards;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.tg-bottom-sheet-small {
    max-height: 50vh;
}

.tg-bottom-sheet-large {
    max-height: 95vh;
}

.tg-bottom-sheet-handle {
    width: 36px;
    height: 4px;
    background: var(--tg-text-tertiary);
    border-radius: 2px;
    margin: var(--tg-spacing-md) auto;
    opacity: 0.3;
}

.tg-bottom-sheet-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 var(--tg-spacing-lg) var(--tg-spacing-lg);
}

#deleteModal .tg-modal-header,
#deleteModal .tg-modal-footer,
#renewModal .tg-modal-header,
#renewModal .tg-modal-footer {
    border-top: none;
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.tg-modal-header {
    padding-bottom: var(--tg-spacing-lg);
    border-bottom: 1px solid var(--tg-border);
    position: relative;
}

.tg-modal-header-multi {
    padding-bottom: var(--tg-spacing-lg);
    border-bottom: 1px solid var(--tg-border);
    margin-bottom: var(--tg-spacing-lg);
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tg-modal-header-multi div {
    width: 32px;
}

.tg-modal-title {
    font-size: var(--tg-font-size-xl);
    font-weight: 600;
    color: var(--tg-text);
}

.tg-modal-subtitle {
    font-size: var(--tg-font-size-sm);
    color: var(--tg-text-secondary);
    margin-top: var(--tg-spacing-xs);
}

.tg-modal-footer {
    padding-top: var(--tg-spacing-lg);
    border-top: 1px solid var(--tg-border);
    margin-top: var(--tg-spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--tg-spacing-sm);
}

.tg-back-button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--tg-accent);
    cursor: pointer;
    padding: 0;
}

/* ============================================
   HINTS & BADGES
   ============================================ */
.tg-hint {
    display: flex;
    align-items: flex-start;
    gap: var(--tg-spacing-sm);
    padding: 0 var(--tg-spacing-md);
    background: var(--tg-bg-secondary);
    border-radius: var(--tg-radius-sm);
    font-size: var(--tg-font-size-sm);
    color: var(--tg-text-secondary);
    line-height: 1.4;
}

.tg-hint svg {
    flex-shrink: 0;
    margin-top: 2px;
}

.status-badge {
    padding: var(--tg-spacing-xs) var(--tg-spacing-md);
    border-radius: var(--tg-radius-sm);
    font-size: var(--tg-font-size-xs);
    font-weight: 500;
}

.status-badge-success {
    background: rgba(52, 199, 89, 0.1);
    color: var(--tg-success);
}

.status-badge-danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--tg-danger);
}

.status-badge-warning {
    background: rgba(255, 149, 0, 0.1);
    color: var(--tg-warning);
}

/* ============================================
   TOGGLE GROUP
   ============================================ */
.tg-toggle-group {
    display: flex;
    gap: var(--tg-spacing-xs);
}

.tg-toggle-button {
    padding: var(--tg-spacing-xs) var(--tg-spacing-md);
    font-size: var(--tg-font-size-sm);
    font-weight: 500;
    background: var(--tg-bg-secondary);
    color: var(--tg-text-secondary);
    border: none;
    border-radius: var(--tg-radius-sm);
    cursor: pointer;
    transition: all var(--tg-transition-fast);
}

.tg-toggle-button.active {
    background: var(--tg-accent);
    color: #FFFFFF;
}

.tg-toggle-button:active {
    transform: scale(0.95);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 768px) {
    .tg-page-content {
        max-width: 600px;
        margin: 0 auto;
    }

    .tg-bottom-nav {
        max-width: 600px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: var(--tg-radius-md) var(--tg-radius-md) 0 0;
    }

    .tg-bottom-sheet {
        max-width: 600px;
        margin: 0 auto;
    }
}

@media (min-width: 1024px) {

    .tg-header-content,
    .tg-page-content {
        max-width: 680px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {

    .tg-bottom-nav,
    .tg-modal,
    .tg-button {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.text-center {
    text-align: center;
}

.mt-0 {
    margin-top: 0;
}

.mt-1 {
    margin-top: var(--tg-spacing-xs);
}

.mt-2 {
    margin-top: var(--tg-spacing-sm);
}

.mt-3 {
    margin-top: var(--tg-spacing-md);
}

.mt-4 {
    margin-top: var(--tg-spacing-lg);
}

.mb-0 {
    margin-bottom: 0;
}

.mb-1 {
    margin-bottom: var(--tg-spacing-xs);
}

.mb-2 {
    margin-bottom: var(--tg-spacing-sm);
}

.mb-3 {
    margin-bottom: var(--tg-spacing-md);
}

.mb-4 {
    margin-bottom: var(--tg-spacing-lg);
}

/* ============================================
   TELEGRAM RIPPLE EFFECT
   ============================================ */
.tg-list-item,
.tg-button,
.result-item,
.domain-card,
.payment-method-content,
.dns-type-button,
.tg-toggle-button {
    position: relative;
    overflow: hidden;
}

.tg-list-item::before,
.tg-button::before,
.result-item::before,
.domain-card::before,
.payment-method-content::before,
.dns-type-button::before,
.tg-toggle-button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
    pointer-events: none;
    z-index: 0;
}

[data-theme="dark"] .tg-list-item::before,
[data-theme="dark"] .tg-button::before,
[data-theme="dark"] .result-item::before,
[data-theme="dark"] .domain-card::before,
[data-theme="dark"] .payment-method-content::before,
[data-theme="dark"] .dns-type-button::before,
[data-theme="dark"] .tg-toggle-button::before {
    background: rgba(255, 255, 255, 0.1);
}

.tg-list-item:active::before,
.tg-button:active::before,
.result-item:active::before,
.domain-card:active::before,
.payment-method-content:active::before,
.dns-type-button:active::before,
.tg-toggle-button:active::before {
    width: 200%;
    height: 200%;
}

/* Ensure content is above ripple */
.tg-list-item>*,
.tg-button>*,
.result-item>*,
.domain-card>*,
.payment-method-content>*,
.dns-type-button>*,
.tg-toggle-button>* {
    position: relative;
    z-index: 1;
}

/* ============================================
   SCROLLBAR STYLING (TELEGRAM STYLE)
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--tg-text-tertiary);
    border-radius: 3px;
    opacity: 0.5;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--tg-text-secondary);
}

/* ============================================
   SELECTION STYLING
   ============================================ */
::selection {
    background: rgba(42, 171, 238, 0.3);
    color: var(--tg-text);
}

button:focus-visible,
a:focus-visible {
    outline-offset: 4px;
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --tg-border: #000000;
        --tg-shadow-sm: 0 0 0 1px rgba(0, 0, 0, 0.2);
        --tg-shadow: 0 0 0 2px rgba(0, 0, 0, 0.3);
        --tg-shadow-lg: 0 0 0 3px rgba(0, 0, 0, 0.4);
    }

    [data-theme="dark"] {
        --tg-border: #FFFFFF;
    }
}

.input-error {
    color: var(--tg-danger);
    font-size: 0.9rem;
    margin: 4px 0 0;
}

.error-outline {
    border-color: var(--tg-danger) !important;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}