
:root {
    --color-bg: #f0f2f5;
    --color-surface: #ffffff;
    --color-primary: #0099cc;          
    --color-primary-dark: #0084c2;
    --color-primary-light: #e6f6fb;
    --color-accent: #313131;           
    --color-text: #1f2733;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --color-border-light: #f1f5f9;
    
    --header-height: 60px;
    --sidebar-width: 320px;          
    
    --color-rail: #0d1b26;
    --color-panel: #12212e;
    --color-rail-icon: #7b8ea0;
    --color-nav-text: #b6c2cf;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--color-text);
    background: var(--color-bg);
}


.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0b2733 0%, #0099cc 100%);
}
.login-container { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { width: 220px; max-width: 100%; height: auto; }
.login-header p {
    color: var(--color-text-muted);
    margin: 12px 0 0;
    font-size: 15px;
    letter-spacing: 0.02em;
}
.login-form .form-group { margin-bottom: 20px; }
.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text);
}
.login-form input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}
.login-form input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0,153,204,0.15);
}
.login-messages { margin-bottom: 20px; }
.login-footer {
    text-align: center;
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    margin-top: 20px;
}

.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 14px; }
.alert-error { background: #fef2f2; color: var(--color-danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }


.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary-light); }


.app-header {
    position: fixed;
    top: 0; left: var(--sidebar-width); right: 0;
    height: var(--header-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px; z-index: 100; box-shadow: var(--shadow);
}
.header-left { display: flex; align-items: center; gap: 16px; }
.header-title { font-size: 18px; font-weight: 700; color: var(--color-primary); letter-spacing: -0.02em; margin: 0; }
.header-right { display: flex; align-items: center; gap: 16px; }
.header-user { font-size: 13px; color: var(--color-text-muted); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.sidebar-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 4px; }
.sidebar-toggle span { display: block; width: 20px; height: 2px; background: var(--color-text); border-radius: 2px; }

.app-body { display: flex; padding-top: var(--header-height); min-height: 100vh; }


.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    display: flex; z-index: 110;
    transition: transform 0.3s ease;
}
.sidebar .rail {
    width: 76px; flex: none;
    background: var(--color-rail);
    display: flex; flex-direction: column; align-items: center;
    padding: 14px 0 12px;
    border-right: 1px solid rgba(255,255,255,0.05);
}
.sidebar .rail-logo {
    width: 40px; height: 40px; border-radius: 10px; flex: none;
    background: var(--color-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 18px; text-decoration: none; margin-bottom: 16px;
}
.sidebar .rail-groups { flex: 1; width: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.sidebar .rail-btn {
    width: 50px; height: 46px; border-radius: 12px; border: none; flex: none;
    cursor: pointer; position: relative;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: var(--color-rail-icon);
    font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
    transition: background 0.12s, color 0.12s;
}
.sidebar .rail-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar .rail-btn.active { background: rgba(0,153,204,0.22); color: #fff; }
.sidebar .panel {
    width: 244px; flex: none; min-width: 0;
    background: var(--color-panel);
    display: flex; flex-direction: column;
    border-right: 1px solid rgba(255,255,255,0.05);
}
.sidebar .panel-group { display: none; flex: 1; min-height: 0; flex-direction: column; }
.sidebar .panel-group.is-open { display: flex; }
.sidebar .panel-head {
    display: flex; align-items: center; gap: 11px; flex: none;
    padding: 19px 18px 15px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar .panel-head span { font-size: 15px; font-weight: 700; color: #f1f5f9; letter-spacing: -0.01em; }
.sidebar .panel-items { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .pn-item {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 12px; border-radius: 8px;
    position: relative; text-decoration: none;
    font-size: 13.5px; font-weight: 500;
    color: var(--color-nav-text);
    transition: background 0.12s, color 0.12s;
}
.sidebar .pn-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar .pn-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .pn-item.active { background: rgba(0,153,204,0.18); color: #fff; }
.sidebar .pn-item.active::before {
    content: ''; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--color-primary);
}
.sidebar .panel-user {
    display: flex; align-items: center; gap: 10px; flex: none;
    padding: 12px 14px; border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar .panel-user .avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: none;
    background: var(--color-primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.sidebar .panel-user .meta { line-height: 1.2; flex: 1; min-width: 0; }
.sidebar .panel-user .name { font-size: 12.5px; font-weight: 600; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .panel-user .sub { font-size: 11px; color: #94a3b8; }
.sidebar .panel-logout { color: var(--color-rail-icon); display: flex; }
.sidebar .panel-logout:hover { color: #fff; }

.main-content { flex: 1; margin-left: var(--sidebar-width); padding: 28px 32px; min-width: 0; }

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow);
}
.card h1 { margin: 0 0 8px; font-size: 22px; color: var(--color-accent); }
.muted { color: var(--color-text-muted); }
.center { text-align: center; }


.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 24px; }
.tile {
    display: flex; flex-direction: column; gap: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 22px;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
.tile-title { font-size: 17px; font-weight: 700; color: var(--color-primary); }
.tile-desc { font-size: 13px; color: var(--color-text-muted); }


.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.page-head h1 { margin: 0; font-size: 22px; color: var(--color-accent); }
.searchbar { display: flex; gap: 8px; }
.searchbar input {
    width: 320px; max-width: 60vw;
    padding: 9px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px; outline: none;
}
.searchbar input:focus { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(0,153,204,0.15); }
.result-info { margin: 4px 0 14px; }


.table-wrap { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
    text-align: left; padding: 12px 16px;
    background: var(--color-border-light);
    color: var(--color-text-muted);
    font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.table tbody td { padding: 11px 16px; border-bottom: 1px solid var(--color-border-light); vertical-align: top; }
.table tbody tr:hover { background: var(--color-primary-light); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .strong { font-weight: 600; color: var(--color-text); }
.table .sub { display: block; font-weight: 400; font-size: 12px; color: var(--color-text-muted); }


.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-success { background: #eafaf1; color: #15803d; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.badge-danger { background: #fef2f2; color: var(--color-danger); }
.badge-info { background: var(--color-primary-light); color: var(--color-primary-dark); }
.badge-amber { background: #fef3c7; color: #92600a; }


.pagination { display: flex; align-items: center; gap: 16px; justify-content: center; margin: 20px 0; }


.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--color-primary); text-decoration: none; font-size: 14px; margin-bottom: 14px; }
.back-link:hover { text-decoration: underline; }
.row-link { color: inherit; text-decoration: none; }
.row-link:hover { color: var(--color-primary); }
.table .num a { color: var(--color-primary); text-decoration: none; font-weight: 600; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-head h1 { margin: 0 0 4px; font-size: 24px; color: var(--color-accent); }
.detail-head .kdnr { color: var(--color-text-muted); font-size: 14px; }


.quick-facts { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.qf { flex: 1 1 140px; min-width: 140px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 11px 16px; box-shadow: var(--shadow); }
.qf-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.qf-value { font-size: 16px; font-weight: 700; color: var(--color-text); margin-top: 3px; }


.detail-cols { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.detail-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

.info-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.info-card > h2 { margin: 0; padding: 13px 18px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-accent); background: var(--color-border-light); border-bottom: 1px solid var(--color-border); display: flex; align-items: center; gap: 8px; }
.info-card > h2 .count { background: var(--color-primary); color: #fff; font-size: 11px; padding: 1px 8px; border-radius: 999px; }
.info-list { display: grid; grid-template-columns: 130px 1fr; gap: 7px 14px; padding: 15px 18px; margin: 0; font-size: 14px; }
.info-list dt { color: var(--color-text-muted); }
.info-list dd { margin: 0; color: var(--color-text); word-break: break-word; }


.card-table { overflow-x: auto; }
.card-table .table thead th { background: transparent; border-bottom: 1px solid var(--color-border); }
.table .row-muted td { color: var(--color-text-muted); }
.card-note { padding: 10px 18px; font-size: 12.5px; color: var(--color-text-muted); border-top: 1px solid var(--color-border-light); }
.note-list { list-style: none; margin: 0; padding: 8px 0; }
.note-list li { padding: 12px 18px; border-bottom: 1px solid var(--color-border-light); }
.note-list li:last-child { border-bottom: none; }
.note-meta { font-size: 12px; color: var(--color-text-muted); margin-bottom: 3px; }
.note-text { font-size: 14px; white-space: pre-line; }


.timeline { list-style: none; margin: 0; padding: 6px 0; }
.timeline li { position: relative; padding: 9px 18px 9px 36px; }
.timeline li::before { content: ''; position: absolute; left: 18px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-primary); }
.timeline li::after { content: ''; position: absolute; left: 21.5px; top: 20px; bottom: -9px; width: 1px; background: var(--color-border); }
.timeline li:last-child::after { display: none; }
.tl-date { font-size: 12px; color: var(--color-text-muted); }
.tl-text { font-size: 14px; margin-top: 2px; }
.empty-hint { padding: 22px 18px; color: var(--color-text-muted); font-size: 14px; text-align: center; }


.spark-list { padding: 10px 18px 4px; display: flex; flex-direction: column; gap: 2px; }
.spark-row { display: grid; grid-template-columns: 1fr 150px 110px; align-items: center; gap: 14px; padding: 6px 0; border-bottom: 1px solid var(--color-border-light); }
.spark-row:last-child { border-bottom: none; }
.spark-name { font-size: 13px; color: var(--color-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spark-graph { color: var(--color-primary-dark); line-height: 0; }
.spark { display: block; }
.spark-val { font-size: 14px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.spark-unit { font-size: 11px; font-weight: 500; color: var(--color-text-muted); margin-left: 4px; }
@media (max-width: 560px) {
    .spark-row { grid-template-columns: 1fr 90px; }
    .spark-row .spark-graph { grid-column: 1 / -1; }
}


.repair-list { list-style: none; margin: 0; padding: 6px 0; }
.repair-list li { padding: 12px 18px; border-bottom: 1px solid var(--color-border-light); }
.repair-list li:last-child { border-bottom: none; }
.rep-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 5px; }
.rep-date { font-weight: 700; font-size: 13px; }
.rep-nr { font-size: 12px; color: var(--color-text-muted); }
.rep-done { font-size: 12px; color: #15803d; }
.rep-line { font-size: 13.5px; line-height: 1.5; white-space: pre-line; }
.rep-lbl { display: inline-block; min-width: 74px; color: var(--color-text-muted); font-size: 12px; }


.messages { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.head-badges { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 7px 14px; border-radius: var(--radius);
    text-decoration: none; font-size: 14px; font-weight: 500;
    color: var(--color-text-muted); border: 1px solid transparent;
}
.tab:hover { background: var(--color-border-light); }
.tab.active { background: var(--color-primary-light); color: var(--color-primary-dark); border-color: var(--color-primary); }
.tab-count { font-size: 12px; font-weight: 700; background: rgba(0,0,0,0.06); padding: 0 7px; border-radius: 999px; }
.tab.active .tab-count { background: #fff; }


.form-card { max-width: 720px; }
.stack-form, .cm-form { padding: 16px 18px; display: flex; flex-direction: column; gap: 16px; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--color-text); }
.form-field input, .form-field select, .form-field textarea,
.cm-form textarea, .status-form select {
    width: 100%; padding: 10px 13px;
    border: 1px solid var(--color-border); border-radius: var(--radius);
    font-size: 14px; font-family: inherit; color: var(--color-text);
    outline: none; transition: border-color var(--transition), box-shadow var(--transition);
    background: #fff;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus,
.cm-form textarea:focus, .status-form select:focus {
    border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(0,153,204,0.15);
}
textarea { resize: vertical; }
.form-actions { display: flex; gap: 10px; }


.ticket-desc { padding: 16px 18px; font-size: 14px; line-height: 1.6; white-space: pre-line; }
.thread { list-style: none; margin: 0; padding: 8px 0; }
.thread li { padding: 12px 18px; border-bottom: 1px solid var(--color-border-light); }
.cm-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.cm-author { font-weight: 700; font-size: 13px; }
.cm-date { font-size: 12px; color: var(--color-text-muted); }
.cm-text { font-size: 14px; line-height: 1.55; white-space: pre-line; }
.cm-form { border-top: 1px solid var(--color-border); }
.cm-form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.status-form { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.field-hint { font-weight: 400; color: var(--color-text-muted); font-size: 12px; }
input[type="file"] { font-size: 13px; color: var(--color-text-muted); }
input[type="file"]::file-selector-button {
    margin-right: 10px; padding: 7px 12px; border-radius: var(--radius);
    border: 1px solid var(--color-border); background: var(--color-border-light);
    color: var(--color-text); font-size: 13px; font-weight: 600; cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: #e9edf2; }


.attach-grid { padding: 14px 18px; display: flex; flex-wrap: wrap; gap: 12px; }
.attach {
    width: 118px; text-decoration: none; color: var(--color-text);
    border: 1px solid var(--color-border); border-radius: var(--radius);
    overflow: hidden; background: #fff; transition: border-color var(--transition), box-shadow var(--transition);
}
.attach:hover { border-color: var(--color-primary); box-shadow: var(--shadow); }
.attach-thumb {
    display: flex; align-items: center; justify-content: center;
    height: 84px; background: var(--color-border-light); overflow: hidden;
}
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-pdf { font-size: 15px; font-weight: 800; letter-spacing: 0.06em; color: var(--color-danger); background: #fef2f2; }
.attach-name { display: block; padding: 7px 9px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


@media (max-width: 1100px) {
    .detail-cols { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar-toggle { display: flex; }
    .app-header { left: 0; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 18px; }
    .header-user { display: none; }
}
@media (max-width: 560px) {
    .pair { grid-template-columns: 1fr; }
}
