/* ============================================================================
 * CSX.UZ — Microsoft Corporate Style
 * Inspired by microsoft.com, Azure Portal, Office 365
 * Clean, flat, professional. Segoe UI, sharp grid, blue accent.
 * ============================================================================ */

:root {
    --bg-page:           #F5F5F5;
    --bg-card:           #FFFFFF;
    --bg-subtle:         #FAFAFA;
    --bg-hover:          #F0F0F0;

    --border-default:    #E0E0E0;
    --border-strong:     #C8C8C8;

    --text-primary:      #1A1A1A;
    --text-secondary:    #616161;
    --text-tertiary:     #9E9E9E;
    --text-on-accent:    #FFFFFF;
    --text-on-dark:      #FFFFFF;

    --accent:            #0078D4;
    --accent-hover:      #106EBE;
    --accent-pressed:    #005A9E;
    --accent-bg:         #E8F4FD;
    --accent-light:      #DEECF9;

    --success:           #107C10;
    --success-bg:        #DFF6DD;
    --warning-bg:        #FFF4CE;
    --error:             #D13438;
    --error-bg:          #FDE7E9;

    --topbar-bg:         #1B1B1B;
    --topbar-text:       #FFFFFF;
    --topbar-hover:      #333333;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.10);

    --radius:    4px;
    --radius-lg: 8px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-page);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

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

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* ============================================================================
 * TOPBAR — Microsoft.com dark header
 * ============================================================================ */
.topbar {
    background: var(--topbar-bg);
    height: 48px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #333;
}
.topbar__inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 0;
}
.topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--topbar-text);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    padding-right: 24px;
    margin-right: 8px;
    border-right: 1px solid #444;
    height: 100%;
}
.topbar__brand:hover { color: var(--topbar-text); text-decoration: none; }
.topbar__logo { width: 21px; height: 21px; flex-shrink: 0; }

.topbar__nav {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 0;
    flex: 1;
}
.topbar__nav a {
    color: #D0D0D0;
    font-size: 13px;
    font-weight: 400;
    padding: 0 16px;
    height: 100%;
    display: flex;
    align-items: center;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: color 100ms, border-color 100ms;
}
.topbar__nav a:hover {
    color: var(--topbar-text);
    text-decoration: none;
    background: var(--topbar-hover);
}
.topbar__nav a.active {
    color: var(--topbar-text);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.topbar__right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}
.topbar__lang {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    border: 1px solid #555;
    border-radius: var(--radius);
    color: #D0D0D0;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.05em;
}
.topbar__lang:hover {
    background: var(--topbar-hover);
    color: var(--topbar-text);
    text-decoration: none;
    border-color: #777;
}
.topbar__link {
    color: #D0D0D0;
    font-size: 13px;
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}
.topbar__link:hover { color: var(--topbar-text); text-decoration: underline; }
.topbar__user {
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar__avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--text-on-accent);
    font-size: 12px;
    font-weight: 700;
}

/* ============================================================================
 * MAIN + FOOTER
 * ============================================================================ */
.main {
    flex: 1;
    padding: 32px 0;
}
.footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-default);
    padding: 16px 0;
    font-size: 12px;
    color: var(--text-tertiary);
}
.footer__inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.footer__links a {
    color: var(--text-tertiary);
    margin-left: 16px;
}
.footer__links a:hover { color: var(--accent); }

/* ============================================================================
 * TYPOGRAPHY
 * ============================================================================ */
h1, h2, h3 {
    font-family: inherit;
    margin: 0 0 16px 0;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.01em;
}
h1 { font-size: 28px; line-height: 1.2; }
h2 { font-size: 20px; line-height: 1.3; margin: 24px 0 12px 0; }
h3 { font-size: 16px; line-height: 1.4; }

p { margin: 0 0 12px 0; }

hr {
    border: 0;
    border-top: 1px solid var(--border-default);
    margin: 20px 0;
}

code, pre, .mono {
    font-family: "Cascadia Code", "Consolas", "Courier New", monospace;
    font-size: 13px;
}

/* ============================================================================
 * CARDS / GROUPBOX
 * ============================================================================ */
.groupbox {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin: 0 0 16px 0;
    box-shadow: var(--shadow-sm);
}
.groupbox__title {
    display: block;
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================================================
 * FORMS
 * ============================================================================ */
.field {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.field__label {
    min-width: 148px;
    font-size: 13px;
    color: var(--text-secondary);
    text-align: right;
}
.field__hint {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 2px;
}

input, textarea, select {
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 8px 12px;
    min-width: 220px;
    transition: border-color 80ms;
    -webkit-appearance: none;
    appearance: none;
}
input:hover, textarea:hover, select:hover {
    border-color: var(--text-secondary);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}
input::placeholder { color: var(--text-tertiary); }

.ip-input {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.ip-input input {
    width: 56px;
    min-width: 0;
    text-align: center;
    padding: 8px 4px;
    font-variant-numeric: tabular-nums;
}
.ip-input .ip-dot { color: var(--text-secondary); font-weight: 600; padding: 0 2px; }
.ip-input .ip-colon { color: var(--text-secondary); font-weight: 600; padding: 0 4px 0 10px; }
.ip-input input.ip-port { width: 80px; font-variant-numeric: tabular-nums; }

/* ============================================================================
 * BUTTONS
 * ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    color: var(--text-primary);
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 8px 20px;
    min-height: 36px;
    min-width: 96px;
    cursor: pointer;
    user-select: none;
    text-decoration: none;
    transition: background 80ms, border-color 80ms;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; color: var(--text-primary); }
.btn:active { background: var(--border-default); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text-on-accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--text-on-accent); }
.btn--primary:active { background: var(--accent-pressed); border-color: var(--accent-pressed); color: var(--text-on-accent); }

.btn--big { padding: 10px 24px; min-height: 40px; font-size: 15px; }

.btn[disabled], .btn--disabled {
    color: var(--text-tertiary);
    background: var(--bg-hover);
    border-color: var(--border-default);
    cursor: not-allowed;
}

.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-default); }
.actions--left { justify-content: flex-start; }
.actions--between { justify-content: space-between; }

.linkbtn {
    background: none;
    border: 0;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font: inherit;
}
.linkbtn:hover { color: var(--accent-hover); text-decoration: underline; }

/* ============================================================================
 * PRICE TAG
 * ============================================================================ */
.price-tag {
    display: inline-block;
    background: var(--accent-bg);
    border: 1px solid var(--accent);
    color: var(--accent-pressed);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}
.price-tag--free {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

/* ============================================================================
 * TABLES
 * ============================================================================ */
table.list {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
table.list th, table.list td {
    padding: 10px 14px;
    font-size: 13px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-default);
}
table.list thead th {
    background: var(--bg-subtle);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-strong);
}
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: var(--bg-subtle); }

/* ============================================================================
 * FLASH MESSAGES
 * ============================================================================ */
.flash {
    border: 1px solid;
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}
.flash--error   { background: var(--error-bg);   border-color: var(--error);   color: var(--error); }
.flash--success { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.flash--info    { background: var(--accent-bg);  border-color: var(--accent);  color: var(--accent-pressed); }
.flash__icon {
    width: 20px; height: 20px; flex: 0 0 20px;
    background: currentColor; color: var(--bg-card);
    border-radius: 50%; text-align: center;
    font-weight: 700; line-height: 20px; font-size: 12px;
}

/* ============================================================================
 * STATUS BADGES
 * ============================================================================ */
.status {
    display: inline-block;
    padding: 3px 10px;
    font-size: 12px;
    border: 1px solid;
    border-radius: 12px;
    font-weight: 600;
}
.status--pending  { background: var(--warning-bg); border-color: #C19C00; color: #745B00; }
.status--paid     { background: var(--accent-bg);  border-color: var(--accent); color: var(--accent-pressed); }
.status--compiled { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.status--failed   { background: var(--error-bg);   border-color: var(--error); color: var(--error); }

/* ============================================================================
 * KEY-VALUE GRID
 * ============================================================================ */
.kv {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 8px 16px;
    margin: 8px 0;
}
.kv dt { color: var(--text-secondary); font-size: 13px; }
.kv dd { margin: 0; color: var(--text-primary); font-size: 14px; word-break: break-all; }

/* ============================================================================
 * SPINNER
 * ============================================================================ */
.hourglass {
    display: inline-block;
    width: 16px; height: 16px;
    vertical-align: middle;
    margin-right: 6px;
    border: 2px solid var(--accent-bg);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================================
 * CONFIG BLOCK
 * ============================================================================ */
.config-block {
    background: #1E1E1E;
    color: #D4D4D4;
    border: 1px solid #333;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    font-family: "Cascadia Code", "Consolas", "Courier New", monospace;
    font-size: 12px;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre;
    margin: 0;
}

::selection { background: var(--accent-light); color: var(--text-primary); }

/* ============================================================================
 * MOBILE
 * ============================================================================ */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .main { padding: 20px 0; }

    .topbar__inner { padding: 0 12px; }
    .topbar__brand { padding-right: 12px; margin-right: 4px; font-size: 14px; }
    .topbar__nav { overflow-x: auto; }
    .topbar__nav a { padding: 0 10px; font-size: 12px; white-space: nowrap; }

    .field { flex-direction: column; align-items: stretch; gap: 4px; }
    .field__label { min-width: 0; text-align: left; font-weight: 600; }
    .kv { grid-template-columns: 1fr; gap: 2px 0; }
    .kv dt { margin-top: 8px; }

    .actions { flex-direction: column; }
    .actions .btn { width: 100%; }

    .ip-input { flex-wrap: wrap; }
    h1 { font-size: 22px; }
    h2 { font-size: 18px; }
}

/* ============================================================================
 * AUTH FORMS — vertical field layout
 * ============================================================================ */
.field--col {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}
.field--col .field__label,
.field__label--block {
    min-width: 0;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
}
.field--col input,
.field--col textarea,
.field--col select {
    min-width: 0;
    width: 100%;
}
.field--col .field__hint {
    margin-top: 4px;
    margin-left: 0;
}

/* Compact forms (auth, order) — full width inputs */
form[style*="max-width"] input,
form[style*="max-width"] textarea,
form[style*="max-width"] select {
    min-width: 0;
    width: 100%;
}
