/* ============================================================
   VORTEX CONTROL HUB — Design System
   Colors: #353535 | #3c6e71 | #ffffff | #d9d9d9 | #284b63
============================================================ */

:root {
    --dark:      #353535;
    --teal:      #3c6e71;
    --teal-dim:  rgba(60,110,113,0.12);
    --teal-dark: #2e5557;
    --navy:      #284b63;
    --navy-dark: #1d3649;
    --white:     #ffffff;
    --gray:      #d9d9d9;
    --gray-mid:  #b0b8bf;
    --gray-dark: #6b7280;
    --bg:        #f0f2f4;
    --surface:   #ffffff;

    --online:    #22c55e;
    --offline:   #94a3b8;
    --warning:   #f59e0b;
    --danger:    #ef4444;

    --sidebar-w: 240px;
    --topbar-h:  60px;
    --radius:    8px;
    --radius-sm: 5px;
    --radius-lg: 14px;
    --shadow:    0 2px 10px rgba(40,75,99,0.10);
    --shadow-md: 0 6px 24px rgba(40,75,99,0.14);
    --transition: all 0.22s ease;

    --font-mono: 'JetBrains Mono', 'Courier New', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--dark);
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ---- Layout ---- */
.hub-layout {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 200;
    transition: transform 0.3s ease;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    min-height: var(--topbar-h);
}

.login-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.change-pw-badge {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--teal-dim);
    color: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin: 0 auto 16px;
}

.temp-pass-display {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--dark);
    background: #f0f2f4;
    border: 2px dashed var(--gray);
    border-radius: var(--radius);
    padding: 14px 24px;
    display: inline-block;
    margin: 8px 0;
    user-select: all;
}

.sidebar-logo-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    filter: brightness(0) invert(1);
}

.sidebar-brand-text {
    color: var(--white);
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
}

.sidebar-brand-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 14px 0;
    overflow-y: auto;
}

.nav-section {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.28);
    padding: 14px 20px 6px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.6);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
}

.sidebar-nav a:hover {
    color: var(--white);
    background: rgba(255,255,255,0.06);
}

.sidebar-nav a.active {
    color: var(--white);
    background: rgba(60,110,113,0.25);
    border-left-color: var(--teal);
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.07);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    letter-spacing: 0.5px;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    color: var(--white);
    font-size: 0.825rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    color: rgba(255,255,255,0.35);
    font-size: 0.7rem;
    text-transform: capitalize;
}

.sidebar-logout {
    color: rgba(255,255,255,0.3);
    font-size: 0.85rem;
    padding: 4px;
    border-radius: 4px;
    transition: var(--transition);
}

.sidebar-logout:hover { color: var(--danger); }

/* ---- Main Content ---- */
.hub-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
    height: var(--topbar-h);
    background: var(--navy);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(40,75,99,0.2);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.65);
    font-size: 1.1rem;
    padding: 6px;
    border-radius: 6px;
    display: none;
    transition: var(--transition);
}

.sidebar-toggle:hover { color: var(--white); background: rgba(255,255,255,0.1); }

.topbar-title {
    color: var(--white);
    font-size: 1rem;
    font-weight: 600;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-badge {
    background: var(--teal);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    letter-spacing: 0.3px;
}

/* ---- Page Content ---- */
.page-content {
    flex: 1;
    padding: 24px;
}

.page-header {
    margin-bottom: 22px;
}

.page-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 3px;
}

.page-header p {
    color: var(--gray-dark);
    font-size: 0.875rem;
}

/* ---- Stats Row ---- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    border-top: 3px solid transparent;
}

.stat-card.teal  { border-top-color: var(--teal); }
.stat-card.navy  { border-top-color: var(--navy); }
.stat-card.green { border-top-color: var(--online); }
.stat-card.amber { border-top-color: var(--warning); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-icon.teal  { background: var(--teal-dim); color: var(--teal); }
.stat-icon.navy  { background: rgba(40,75,99,0.1); color: var(--navy); }
.stat-icon.green { background: rgba(34,197,94,0.1); color: var(--online); }
.stat-icon.amber { background: rgba(245,158,11,0.1); color: var(--warning); }

.stat-body { flex: 1; min-width: 0; }
.stat-label { font-size: 0.75rem; color: var(--gray-dark); font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--dark); font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-sub { font-size: 0.75rem; color: var(--gray-dark); margin-top: 2px; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid #eef0f3;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--teal); }

.card-body { padding: 20px; }

/* ---- Grid Layouts ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }

/* ---- Device Cards ---- */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}

.device-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border-left: 4px solid var(--gray);
    transition: var(--transition);
}

.device-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.device-card.online-card  { border-left-color: var(--teal); }
.device-card.offline-card { border-left-color: var(--gray-mid); }
.device-card.alert-card   { border-left-color: var(--warning); }

.device-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    gap: 10px;
}

.device-name-block { flex: 1; min-width: 0; }

.device-name {
    font-weight: 700;
    font-size: 0.925rem;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-id {
    font-size: 0.72rem;
    color: var(--gray-dark);
    font-family: var(--font-mono);
}

.device-card-body { padding: 0 16px 16px; }

.device-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f0f2f4;
    font-size: 0.825rem;
}

.device-row:last-child { border-bottom: none; }
.device-row-label { color: var(--gray-dark); }
.device-row-value { font-weight: 600; color: var(--dark); font-family: var(--font-mono); }

.device-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #f0f2f4;
    flex-wrap: wrap;
}

/* ---- Valve Toggle ---- */
.valve-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8f9fb;
    border-bottom: 1px solid #eef0f3;
}

.valve-state-label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.valve-state-label.open  { color: var(--teal); }
.valve-state-label.closed { color: var(--gray-dark); }
.valve-state-label.error { color: var(--danger); }

/* Industrial toggle switch */
.toggle-switch {
    position: relative;
    width: 56px;
    height: 28px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray);
    border-radius: 28px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid rgba(0,0,0,0.08);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--white);
    border-radius: 50%;
    left: 2px;
    top: 2px;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--teal); border-color: var(--teal-dark); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(28px); }
.toggle-switch input:disabled + .toggle-slider { opacity: 0.5; cursor: not-allowed; }

.toggle-switch-sm {
    width: 40px;
    height: 22px;
}

.toggle-switch-sm .toggle-slider::before {
    width: 14px;
    height: 14px;
    left: 2px;
    top: 2px;
}

.toggle-switch-sm input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ---- Valve Angle Dial ---- */
.valve-dial-wrap {
    position: relative;
    padding: 14px 16px 4px;
    background: #f8f9fb;
    border-bottom: 1px solid #eef0f3;
}

.valve-dial-svg { display: block; width: 100%; height: auto; touch-action: none; }

.valve-dial-track { fill: none; stroke: #e2e6ea; stroke-width: 12; stroke-linecap: round; }
.valve-dial-progress { fill: none; stroke: var(--teal); stroke-width: 12; stroke-linecap: round; }
.valve-dial-progress.error { stroke: var(--danger); }

.valve-dial-tick { stroke: var(--gray-mid); stroke-width: 2; }
.valve-dial-tick-label { font-size: 11px; fill: var(--gray-dark); font-family: var(--font-mono); }

.valve-dial-handle {
    fill: var(--white);
    stroke: var(--teal);
    stroke-width: 4;
    cursor: grab;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.25));
}
.valve-dial-handle:active,
.valve-dial-handle.dragging { cursor: grabbing; }
.valve-dial-handle.disabled { stroke: var(--gray-mid); cursor: default; }
.valve-dial-handle:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.valve-dial-center {
    position: absolute;
    left: 0; right: 0;
    bottom: 8px;
    text-align: center;
    pointer-events: none;
}

.valve-dial-value { font-size: 1.7rem; font-weight: 700; font-family: var(--font-mono); color: var(--dark); line-height: 1; }
.valve-dial-value .deg { font-size: 1rem; font-weight: 600; color: var(--gray-dark); }

.valve-dial-feedback-row {
    text-align: center;
    padding: 2px 16px 8px;
    background: #f8f9fb;
    border-bottom: 1px solid #eef0f3;
    font-family: var(--font-mono);
}

.valve-quick-actions {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: #f8f9fb;
    border-bottom: 1px solid #eef0f3;
}
.valve-quick-actions .btn { flex: 1; }
.valve-quick-actions .btn.active { background: var(--teal); color: var(--white); border-color: var(--teal); }

.card-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-dark);
    margin: 12px 0 8px;
}

/* ---- Sensor Value Display ---- */
.sensor-value-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 16px 14px;
    background: #f8f9fb;
    border-bottom: 1px solid #eef0f3;
    text-align: center;
    gap: 4px;
}

.sensor-type-icon {
    font-size: 1.3rem;
    color: var(--teal);
    margin-bottom: 2px;
}

.sensor-big-value {
    font-size: 2.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--dark);
    line-height: 1;
}

.sensor-alert .sensor-big-value { color: var(--danger); }
.sensor-alert { border-left-color: var(--danger) !important; }

.sensor-unit {
    font-size: 0.85rem;
    color: var(--gray-dark);
    font-weight: 400;
}

.sensor-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.825rem;
}

.sensor-history-table th {
    text-align: left;
    padding: 8px 10px;
    background: #f0f2f4;
    color: var(--gray-dark);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sensor-history-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f2f4;
}

.sensor-history-table tbody tr:hover { background: #f8f9fb; }

.sensor-value-big {
    font-size: 2.4rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--dark);
    line-height: 1;
}

.sensor-range-bar {
    height: 6px;
    background: #eef0f3;
    border-radius: 3px;
    overflow: hidden;
    margin: 8px 0;
}

.sensor-range-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--teal);
    transition: width 0.5s ease;
}

.sensor-range-fill.in-range  { background: var(--teal); }
.sensor-range-fill.out-range { background: var(--danger); }

/* ---- Status Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-online  { background: rgba(34,197,94,0.12);  color: #15803d; }
.badge-offline { background: rgba(148,163,184,0.15); color: #64748b; }
.badge-warning { background: rgba(245,158,11,0.12); color: #b45309; }
.badge-danger  { background: rgba(239,68,68,0.12);  color: #b91c1c; }
.badge-teal    { background: var(--teal-dim);        color: var(--teal-dark); }
.badge-navy    { background: rgba(40,75,99,0.1);     color: var(--navy-dark); }

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.online  { background: var(--online); box-shadow: 0 0 0 2px rgba(34,197,94,0.25); animation: pulse-dot 2s infinite; }
.status-dot.offline { background: var(--offline); }

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.25); }
    50%       { box-shadow: 0 0 0 4px rgba(34,197,94,0.12); }
}

/* ---- Mode Selector Pills ---- */
.mode-selector {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: #f0f2f4;
    border-radius: var(--radius-sm);
}

.mode-btn {
    flex: 1;
    padding: 5px 8px;
    border: none;
    background: none;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--gray-dark);
    transition: var(--transition);
    cursor: pointer;
    white-space: nowrap;
}

.mode-btn.active {
    background: var(--white);
    color: var(--navy);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-dark); }

.btn-navy { background: var(--navy); color: var(--white); }
.btn-navy:hover { background: var(--navy-dark); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
    background: none;
    color: var(--gray-dark);
    border: 1px solid var(--gray);
}

.btn-ghost:hover { background: #f0f2f4; color: var(--dark); }

.btn-sm { padding: 5px 10px; font-size: 0.75rem; }
.btn-icon { padding: 6px 8px; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Forms ---- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    min-width: 0;
}

.form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--dark);
    letter-spacing: 0.2px;
}

.form-control {
    width: 100%;
    min-width: 0;
    padding: 9px 12px;
    border: 1.5px solid var(--gray);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--dark);
    background: var(--white);
    transition: var(--transition);
    outline: none;
    appearance: none;
}

.form-control:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-dim);
}

.form-control::placeholder { color: var(--gray-mid); }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 0.73rem; color: var(--gray-dark); }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    padding: 10px 16px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--gray-dark);
    background: #f8f9fb;
    border-bottom: 1px solid #eef0f3;
    white-space: nowrap;
}

tbody td {
    padding: 12px 16px;
    font-size: 0.855rem;
    color: var(--dark);
    border-bottom: 1px solid #f0f2f4;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }

.td-mono { font-family: var(--font-mono); font-size: 0.82rem; }
.td-muted { color: var(--gray-dark); }

/* ---- Modals ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(30,40,50,0.55);
    backdrop-filter: blur(4px);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px rgba(40,75,99,0.22);
    animation: modal-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-lg { max-width: 680px; }

@keyframes modal-in {
    from { opacity: 0; transform: scale(0.88) translateY(16px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 14px;
    border-bottom: 1px solid #eef0f3;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    color: var(--gray-dark);
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover { background: #f0f2f4; color: var(--dark); }

.modal-body { padding: 20px 22px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid #eef0f3;
}

/* ---- Activity Feed ---- */
.activity-list { display: flex; flex-direction: column; }

.activity-item {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f2f4;
    align-items: flex-start;
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--teal);
    margin-top: 6px;
    flex-shrink: 0;
}

.activity-text { font-size: 0.83rem; color: var(--dark); flex: 1; }
.activity-time { font-size: 0.73rem; color: var(--gray-dark); white-space: nowrap; }
.activity-device { font-size: 0.72rem; color: var(--teal); font-family: var(--font-mono); margin-top: 2px; }

/* ---- Schedule Builder ---- */
.schedule-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }

.schedule-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #f8f9fb;
    border-radius: var(--radius-sm);
    border: 1px solid #eef0f3;
}

.schedule-entry .form-control { padding: 5px 8px; font-size: 0.8rem; }
.schedule-remove { background: none; border: none; color: var(--danger); font-size: 0.9rem; padding: 4px; cursor: pointer; opacity: 0.6; transition: var(--transition); }
.schedule-remove:hover { opacity: 1; }

/* ---- Alerts ---- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.83rem;
    margin-bottom: 14px;
}

.alert-info    { background: rgba(40,75,99,0.08);  color: var(--navy-dark); }
.alert-success { background: rgba(34,197,94,0.1);  color: #15803d; }
.alert-warning { background: rgba(245,158,11,0.1); color: #92400e; }
.alert-error   { background: rgba(239,68,68,0.1);  color: #991b1b; }

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    background: var(--dark);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 500px;
    height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(60,110,113,0.2) 0%, transparent 70%);
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: -5%;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(40,75,99,0.25) 0%, transparent 70%);
    pointer-events: none;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 36px;
    box-shadow: 0 32px 80px rgba(0,0,0,0.35);
    position: relative;
    z-index: 1;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.login-brand-icon {
    width: 42px;
    height: 42px;
    background: var(--teal);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
}

.login-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.login-brand-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--gray-dark);
}

.login-card h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 6px;
}

.login-card p {
    color: var(--gray-dark);
    font-size: 0.875rem;
    margin-bottom: 26px;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

.input-group {
    position: relative;
    width: 100%;
    min-width: 0;
}

.input-group .form-control { padding-left: 40px; }
.input-group:has(.icon-right) .form-control { padding-right: 40px; }

.input-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-mid);
    font-size: 0.85rem;
    pointer-events: none;
}

.icon-right {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-mid);
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-login {
    background: var(--teal);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    letter-spacing: 0.3px;
}

.btn-login:hover { background: var(--teal-dark); }

.login-msg {
    font-size: 0.83rem;
    text-align: center;
    padding: 8px;
    border-radius: var(--radius-sm);
    display: none;
}

.login-msg.error   { background: rgba(239,68,68,0.1); color: #991b1b; display: block; }
.login-msg.success { background: rgba(34,197,94,0.1); color: #15803d; display: block; }

/* Secondary escape link under a login-card form (change_password.php) */
.login-foot-link {
    margin-top: 16px;
    text-align: center;
    font-size: 0.82rem;
}
.login-foot-link a { color: var(--gray-dark); text-decoration: none; }
.login-foot-link a:hover { color: var(--teal); }

/* ---- Chart Container ---- */
.chart-container { position: relative; height: 260px; }

/* ---- Utility ---- */
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.flex-center  { display: flex; align-items: center; justify-content: center; gap: 10px; }
.flex-gap     { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-14 { margin-bottom: 14px; }
.mb-18 { margin-bottom: 18px; }
.text-sm   { font-size: 0.83rem; }
.text-xs   { font-size: 0.73rem; }
.text-muted { color: var(--gray-dark); }
.text-teal  { color: var(--teal); }
.text-navy  { color: var(--navy); }
.text-danger { color: var(--danger); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mono   { font-family: var(--font-mono); }
.w-full { width: 100%; }
.divider { height: 1px; background: #eef0f3; margin: 12px 0; }

/* ---- Toast Notifications ---- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.toast {
    background: var(--dark);
    color: var(--white);
    padding: 12px 18px;
    border-radius: var(--radius);
    font-size: 0.83rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in 0.3s ease;
    max-width: 320px;
}

.toast.success { border-left: 3px solid var(--online); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--teal); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ---- Analytics ---- */
.analytics-controls {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.chart-wrap {
    position: relative;
    min-height: 300px;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--gray-dark);
    font-size: 0.875rem;
}

.chart-empty i {
    font-size: 2rem;
    color: var(--gray);
}

/* ---- Device Management ---- */
.device-summary-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.summary-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--white);
    border: 1px solid var(--gray);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--dark);
    box-shadow: var(--shadow);
}

.summary-pill.warning { border-color: var(--warning); color: #b45309; }
.summary-pill.online  { border-color: var(--online);  color: #15803d; }

.filter-tabs {
    display: flex;
    gap: 4px;
}

.filter-tab {
    padding: 4px 12px;
    border: 1px solid var(--gray);
    background: var(--white);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-dark);
    cursor: pointer;
    transition: var(--transition);
}

.filter-tab:hover  { background: var(--bg); }
.filter-tab.active { background: var(--navy); border-color: var(--navy); color: var(--white); }

.server-key-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--gray-dark);
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: var(--transition);
}

.btn-icon:hover { color: var(--teal); background: var(--teal-dim); }

.assign-search-wrap {
    position: relative;
    margin-bottom: 12px;
}

.assign-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-dark);
    font-size: 0.8rem;
    pointer-events: none;
}

.assign-search-input {
    padding-left: 32px !important;
}

.assign-device-list {
    max-height: 280px;
    overflow-y: auto;
}

#assignUserList {
    min-height: 60px;
}

.assign-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding-top: 10px;
    border-top: 1px solid #f0f2f4;
    margin-top: 8px;
}

.page-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 6px;
    border: 1px solid var(--gray);
    background: var(--white);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--dark);
    cursor: pointer;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) { background: var(--bg); border-color: var(--teal); color: var(--teal); }
.page-btn.active  { background: var(--navy); border-color: var(--navy); color: var(--white); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ---- Device Assignment ---- */
.assign-row {
    border-bottom: 1px solid #f0f2f4;
    padding: 4px 0;
}

.assign-check {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.assign-check:hover { background: #f8f9fb; }

.assign-check input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--teal);
    flex-shrink: 0;
    cursor: pointer;
}

.assign-device-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .grid-3    { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .hub-main {
        margin-left: 0;
    }
    .sidebar-toggle { display: flex; }
    .page-content { padding: 16px; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .device-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr; }
    .login-card { padding: 24px; }
}
