/* ============================================================================
 * PIKAR req_service — общая система дизайна.
 *
 * Файл является точным переносом дизайн-токенов PIKAR Cloud
 * (`cloud/web/src/style.css`), которые, в свою очередь, повторяют
 * дизайн-токены PIKAR Desktop (`desktop/frontend/src/style.css`):
 *   - та же цветовая палитра (dark/light), акценты, статусные цвета;
 *   - та же типографика (Golos Text), шкала размеров, веса, line-heights;
 *   - те же спейсинг, радиусы, тени, скроллбар и состояния контролов.
 * Любое расхождение с Cloud/Desktop считается дефектом паритета.
 * ========================================================================== */

/* ============================================================================
 * Golos Text font face declarations.
 * Variable font files cover weights 400–700 in a single woff2 per subset.
 * ========================================================================== */

@font-face {
    font-family: "Golos Text";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("assets/fonts/Golos-Text-latin.woff2") format("woff2-variations"),
        url("assets/fonts/Golos-Text-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
        U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC,
        U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "Golos Text";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("assets/fonts/Golos-Text-latin-ext.woff2") format("woff2-variations"),
        url("assets/fonts/Golos-Text-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F,
        U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F,
        U+A720-A7FF;
}

@font-face {
    font-family: "Golos Text";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("assets/fonts/Golos-Text-cyrillic.woff2") format("woff2-variations"),
        url("assets/fonts/Golos-Text-cyrillic.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}

@font-face {
    font-family: "Golos Text";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("assets/fonts/Golos-Text-cyrillic-ext.woff2") format("woff2-variations"),
        url("assets/fonts/Golos-Text-cyrillic-ext.woff2") format("woff2");
    unicode-range: U+0460-052F, U+1C80-1C88, U+20B4, U+2DE0-2DFF, U+A640-A69F,
        U+FE2E-FE2F;
}

/* ============================================================================
 * Typography tokens — a single, strictly stepped type scale.
 * ========================================================================== */

:root {
    /* Font family — the ONLY typeface used across the whole application. */
    --font-sans: "Golos Text", -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Type scale (font-size). */
    --fs-xs: 0.75rem;
    /* 12px — captions, badges, footer */
    --fs-sm: 0.8125rem;
    /* 13px — secondary text, table cells */
    --fs-base: 0.875rem;
    /* 14px — body text, form controls (default) */
    --fs-md: 1rem;
    /* 16px — emphasized body, inputs */
    --fs-lg: 1.125rem;
    /* 18px — subheadings, card titles */
    --fs-xl: 1.25rem;
    /* 20px — section headers */
    --fs-2xl: 1.5rem;
    /* 24px — page titles */
    --fs-3xl: 2rem;
    /* 32px — hero / display */

    /* Font weights. */
    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* Line heights. */
    --lh-tight: 1.2;
    --lh-snug: 1.35;
    --lh-normal: 1.55;
    --lh-relaxed: 1.7;

    /* Letter spacing. */
    --ls-tight: -0.01em;
    --ls-normal: 0;
    --ls-wide: 0.02em;
    --ls-wider: 0.04em;

    /* Spacing scale (rem-based, 4px grid). */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;

    /* Radii. */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 999px;
}

/* ============================================================================
 * Design tokens — dark theme (default).
 * ========================================================================== */

:root,
:root[data-theme="dark"] {
    /* Surfaces */
    --bg-primary: #0e1217;
    --bg-secondary: #161b22;
    --bg-elevated: #1c232c;
    --bg-card: #1c232c;
    --bg-input: #0b1014;
    --bg-overlay: rgba(0, 0, 0, 0.72);

    /* Text */
    --text-primary: #f5f7fa;
    --text-secondary: #b8c0cc;
    --text-muted: #8a93a3;
    --text-inverse: #0e1217;

    /* Borders / dividers */
    --border: #2a313c;
    --border-strong: #3a4250;
    --focus-ring: rgba(0, 112, 192, 0.45);

    /* Brand accent (blue) */
    --accent: #0070C0;
    --accent-hover: #1a8ad4;
    --accent-active: #005a9c;
    --accent-soft: rgba(0, 112, 192, 0.14);
    --accent-fg: #ffffff;

    /* Secondary accent (success / green) */
    --success: #3fb950;
    --success-soft: rgba(63, 185, 80, 0.16);
    --success-fg: #7ee787;

    /* Warning */
    --warning: #d29922;
    --warning-soft: rgba(210, 153, 34, 0.16);
    --warning-fg: #f0c674;

    /* Danger */
    --danger: #f85149;
    --danger-soft: rgba(248, 81, 73, 0.16);
    --danger-fg: #ff9b95;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.45);

    /* Scrollbar */
    --scrollbar-track: transparent;
    --scrollbar-thumb: #3a4250;
    --scrollbar-thumb-hover: #4a5260;

    color-scheme: dark;
}

/* ============================================================================
 * Light theme override — applied when [data-theme="light"] is set on <html>.
 * ========================================================================== */

:root[data-theme="light"] {
    --bg-primary: #f6f8fb;
    --bg-secondary: #ffffff;
    --bg-elevated: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-overlay: rgba(15, 23, 42, 0.45);

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-inverse: #ffffff;

    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --focus-ring: rgba(0, 112, 192, 0.28);

    --accent: #0070C0;
    --accent-hover: #005a9c;
    --accent-active: #004a80;
    --accent-soft: rgba(0, 112, 192, 0.10);
    --accent-fg: #ffffff;

    --success: #15803d;
    --success-soft: rgba(21, 128, 61, 0.12);
    --success-fg: #166534;

    --warning: #b45309;
    --warning-soft: rgba(180, 83, 9, 0.12);
    --warning-fg: #92400e;

    --danger: #b91c1c;
    --danger-soft: rgba(185, 28, 28, 0.10);
    --danger-fg: #991b1b;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

    --scrollbar-track: transparent;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-thumb-hover: #94a3b8;

    color-scheme: light;
}

/* ============================================================================
 * Base reset + typography.
 * ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-feature-settings: "ss01", "cv11";
    font-weight: var(--fw-regular);
    font-size: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    margin: 0;
    min-height: 100vh;
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    transition:
        background-color 220ms ease,
        color 220ms ease;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-sans);
    font-weight: var(--fw-semibold);
    letter-spacing: var(--ls-tight);
    color: var(--text-primary);
    margin: 0;
    line-height: var(--lh-tight);
}

h1 {
    font-size: var(--fs-3xl);
    font-weight: var(--fw-bold);
}

h2 {
    font-size: var(--fs-2xl);
}

h3 {
    font-size: var(--fs-xl);
}

h4 {
    font-size: var(--fs-lg);
}

h5 {
    font-size: var(--fs-md);
}

h6 {
    font-size: var(--fs-base);
}

p,
span,
li,
td,
th,
label,
small,
strong,
em,
code,
pre,
button,
input,
select,
textarea,
a {
    font-family: var(--font-sans);
}

code,
pre {
    font-family: var(--font-sans);
    font-feature-settings: "tnum" 1, "ss01" 1;
    letter-spacing: 0.01em;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input,
select,
textarea {
    font-family: inherit;
    color: inherit;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* ============================================================================
 * Smooth transitions for theme switching.
 * ========================================================================== */

html,
body,
main,
aside,
section,
header,
footer,
nav,
.card,
.panel,
.modal-content,
button,
input,
select,
textarea,
.tag,
.badge,
.chip,
.pill {
    transition:
        background-color 220ms ease,
        color 220ms ease,
        border-color 220ms ease,
        box-shadow 220ms ease,
        fill 220ms ease,
        stroke 220ms ease;
}

/* ============================================================================
 * Form controls — light/dark aware defaults.
 * ========================================================================== */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
input:not([type]),
select,
textarea {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-size: var(--fs-base);
    line-height: var(--lh-normal);
    outline: none;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background-color 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================================================
 * Buttons — consistent base.
 * ========================================================================== */

button {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-4);
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    line-height: var(--lh-tight);
    transition:
        background-color 160ms ease,
        color 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease;
}

button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ============================================================================
 * Tables.
 * ========================================================================== */

table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    color: var(--text-primary);
    font-size: var(--fs-sm);
}

th,
td {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    font-size: var(--fs-xs);
    text-transform: uppercase;
    letter-spacing: var(--ls-wide);
}

tbody tr:hover {
    background-color: var(--bg-elevated);
}

/* ============================================================================
 * Scrollbar — themed for both modes.
 * ========================================================================== */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-md);
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: padding-box;
    border: 2px solid transparent;
}

/* ============================================================================
 * Selection.
 * ========================================================================== */

::selection {
    background-color: var(--accent-soft);
    color: var(--text-primary);
}

/* ============================================================================
 * Legacy class bridge — кнопки, статусы, бейджи.
 * ========================================================================== */

button.secondary {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border);
}

button.secondary:hover:not(:disabled) {
    background-color: var(--bg-secondary);
    border-color: var(--border-strong);
}

button.danger {
    background-color: var(--danger);
    color: var(--accent-fg);
    border-color: var(--danger);
}

button.danger:hover:not(:disabled) {
    filter: brightness(1.08);
}

.error {
    color: var(--danger);
    font-size: var(--fs-sm);
    line-height: var(--lh-normal);
}

.success {
    color: var(--success);
    font-size: var(--fs-sm);
    line-height: var(--lh-normal);
}

.muted {
    color: var(--text-muted);
}

/* Golos Text is the only typeface; inline "code-like" text uses tabular
 * figures instead of a separate monospace stack. */
.mono {
    font-family: var(--font-sans);
    font-feature-settings: "tnum" 1, "ss01" 1;
    letter-spacing: 0.01em;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    letter-spacing: var(--ls-wider);
    line-height: var(--lh-tight);
}

.badge.ok {
    background-color: var(--success-soft);
    color: var(--success);
}

.badge.off {
    background-color: var(--bg-elevated);
    color: var(--text-muted);
}

/* ============================================================================
 * Reduced motion.
 * ========================================================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
    }
}