:root {
    --bg: #101712;
    --bg-soft: #17211a;
    --panel: #1d2a20;
    --panel-2: #243328;
    --border: #314437;
    --primary: #3f6b45;
    --primary-hover: #4f8156;
    --accent: #7da16f;
    --text: #e8efe8;
    --text-soft: #b6c3b7;
    --danger: #8f3b3b;
    --warning: #8a6a2b;
    --success: #2f6a44;
    --info: #35586a;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: Arial, sans-serif;
    background: linear-gradient(180deg, #0d140f 0%, #131d16 100%);
    color: var(--text);
}

body {
    display: flex;
}

a {
    color: inherit;
    text-decoration: none;
}

.sidebar {
    width: 270px;
    height: 100vh;
    background: linear-gradient(180deg, #121a14 0%, #18231b 100%);
    border-right: 1px solid var(--border);
    padding: 24px 18px;
    position: fixed;
    top: 0;
    left: 0;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.brand-badge {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: var(--shadow);
}

.sidebar-brand h2 {
    margin: 0;
    font-size: 20px;
}

.sidebar-brand p {
    margin: 4px 0 0;
    color: var(--text-soft);
    font-size: 13px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-nav a {
    position: relative;
    display: block;
    color: var(--text-soft);
    padding: 12px 4px;
    border-radius: 0;
    background: transparent;
    border: none;
    transition: color 0.2s ease;
    font-weight: bold;
    overflow: hidden;
}

.sidebar-nav a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 6px;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #ffffff 0%, #f8fff8 45%, #dfe8df 100%);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.55);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.28s ease;
}

.sidebar-nav a:hover {
    color: #ffffff;
    background: transparent;
    transform: none;
}

.sidebar-nav a:hover::after {
    transform: scaleX(1);
}

.sidebar-nav a.active {
    color: #ffffff;
}

.sidebar-nav a.active::after {
    transform: scaleX(1);
}

.main-wrapper {
    flex: 1;
    min-width: 0;
    margin-left: 270px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px 10px;
}

.topbar h1 {
    margin: 0;
    font-size: 28px;
}

.topbar-subtitle {
    display: inline-block;
    margin-top: 6px;
    color: var(--text-soft);
    font-size: 14px;
}

.topbar-user {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--text-soft);
}

.content {
    padding: 10px 28px 28px;
}

.card {
    background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.grid.two-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.big-number {
    font-size: 40px;
    font-weight: bold;
    margin: 16px 0 8px;
    color: #ffffff;
}

.alert-card {
    border-left: 6px solid #b0893c;
}

.button-link,
button {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 11px 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s ease;
}

.button-link:hover,
button:hover {
    background: var(--primary-hover);
}

.login-card {
    max-width: 430px;
    margin: 70px auto;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--text);
}

input,
select {
    width: 100%;
    padding: 12px 13px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: #111914;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(125, 161, 111, 0.15);
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table th {
    color: var(--accent);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table td {
    color: var(--text);
}

table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.flash-wrapper {
    margin-bottom: 18px;
}

.flash {
    padding: 14px 16px;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 1px solid transparent;
    font-weight: bold;
}

.flash-success {
    background: rgba(47, 106, 68, 0.25);
    border-color: rgba(47, 106, 68, 0.6);
}

.flash-danger {
    background: rgba(143, 59, 59, 0.25);
    border-color: rgba(143, 59, 59, 0.6);
}

.flash-warning {
    background: rgba(138, 106, 43, 0.25);
    border-color: rgba(138, 106, 43, 0.6);
}

.flash-info {
    background: rgba(53, 88, 106, 0.25);
    border-color: rgba(53, 88, 106, 0.6);
}

.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    color: var(--text-soft);
}

.checkbox-list input {
    width: auto;
    margin: 0;
}

h2, h3 {
    margin-top: 0;
}

@media (max-width: 1100px) {
    .grid,
    .grid.two-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-height: auto;
        position: relative;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

.filter-form {
    display: flex;
    gap: 12px;
    align-items: end;
}

.filter-form .form-group {
    flex: 1;
    margin-bottom: 0;
}

.filter-form button {
    width: auto;
    min-width: 120px;
}

@media (max-width: 900px) {
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-form button {
        width: 100%;
    }
}

.company-chart {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.company-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.company-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-weight: bold;
    color: var(--text);
}

.company-name {
    max-width: 80%;
    word-break: break-word;
}

.company-value {
    color: #ffffff;
}

.company-bar-track {
    width: 100%;
    height: 14px;
    border-radius: 999px;
    background: #111914;
    border: 1px solid var(--border);
    overflow: hidden;
}

.company-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #8ea87e 0%, #dce9d6 100%);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.18);
}

.dashboard-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-actions form {
    margin: 0;
}

.dashboard-actions button {
    width: auto;
    min-width: 220px;
}

@media (max-width: 900px) {
    .dashboard-actions {
        flex-direction: column;
    }

    .dashboard-actions button {
        width: 100%;
        min-width: 100%;
    }
}

.muted-text {
    color: var(--text-soft);
    font-size: 14px;
}

.highlight-card {
    margin: 18px 0;
    border: 1px solid rgba(220, 233, 214, 0.22);
    background: linear-gradient(180deg, rgba(125, 161, 111, 0.10) 0%, rgba(36, 51, 40, 0.95) 100%);
}

.device-link-card h3 {
    margin-bottom: 14px;
}

.info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-success {
    background: rgba(47, 106, 68, 0.22);
    color: #dff7e6;
    border: 1px solid rgba(47, 106, 68, 0.6);
}

.status-warning {
    background: rgba(138, 106, 43, 0.22);
    color: #f8e7bf;
    border: 1px solid rgba(138, 106, 43, 0.6);
}

.action-button {
    width: 100%;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 18px 18px;
    border-radius: 14px;
    border: 1px solid transparent;
    box-shadow: var(--shadow);
}

.action-button-title {
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
}

.action-button-subtitle {
    font-size: 13px;
    color: rgba(255,255,255,0.82);
    text-align: left;
}

.action-button-primary {
    background: linear-gradient(135deg, #426f4a 0%, #5f8c62 100%);
    border-color: rgba(220, 233, 214, 0.18);
}

.action-button-primary:hover {
    background: linear-gradient(135deg, #4d7d56 0%, #6f9c73 100%);
    transform: translateY(-1px);
}

.action-button-secondary {
    background: linear-gradient(135deg, #2d4632 0%, #46624d 100%);
    border-color: rgba(220, 233, 214, 0.14);
}

.action-button-secondary:hover {
    background: linear-gradient(135deg, #36543c 0%, #517058 100%);
    transform: translateY(-1px);
}

.status-badge {
    all: unset;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    min-width: 110px;
    padding: 8px 12px;
    border-left: 4px solid;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.03);
}

.status-indicator.status-warning {
    color: #f0d78a;
    border-left-color: #b0893c;
    background: rgba(176, 137, 60, 0.10);
}

.status-indicator.status-success {
    color: #cfe8d2;
    border-left-color: #4f8156;
    background: rgba(79, 129, 86, 0.12);
}


.clickable-table tbody tr.clickable-row {
    cursor: pointer;
    transition: background 0.18s ease, transform 0.18s ease;
}

.clickable-table tbody tr.clickable-row:hover td {
    background: rgba(255, 255, 255, 0.045);
}

.clickable-table tbody tr.clickable-row:active {
    transform: scale(0.998);
}

.checkbox-line {
    margin-top: 18px;
    margin-bottom: 18px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    color: var(--text);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

.status-indicator.status-neutral {
    color: #d8dde3;
    border-left-color: #7f8a96;
    background: rgba(127, 138, 150, 0.14);
}

.sortable-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    text-decoration: none;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sortable-header:hover {
    color: #dce9d6;
}

.sort-indicator {
    font-size: 11px;
    line-height: 1;
}

.quick-actions-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
}

.quick-actions-left {
    flex: 1;
}

.quick-actions-right {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.schedule-box h4 {
    margin: 0 0 8px 0;
    color: var(--accent);
}

.schedule-box p {
    margin: 0;
    color: var(--text);
    font-weight: bold;
}

.json-preview {
    white-space: pre-wrap;
    word-break: break-word;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    color: var(--text-soft);
    font-size: 12px;
}

.inner-card {
    margin-top: 12px;
}

@media (max-width: 1100px) {
    .quick-actions-header {
        flex-direction: column;
    }

    .quick-actions-right {
        width: 100%;
    }
}

@media (max-width: 900px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        left: auto;
        top: auto;
        overflow-y: visible;
    }

    .main-wrapper {
        margin-left: 0;
    }
}
