/* ============================================================
   DirectLock Admin Panel - light theme (green accent)
   ============================================================ */
:root {
    --bg: #f3f5f7;
    --sidebar: #ffffff;
    --card: #ffffff;
    --border: #e6e8ec;
    --text: #1f2733;
    --muted: #707887;
    --accent: #16a34a;
    --accent-dark: #15803d;
    --accent-soft: #e8f6ee;
    --grad: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    --danger: #dc2626;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
    --shadow-md: 0 4px 16px rgba(16, 24, 40, .09);
    --shadow-lg: 0 18px 44px rgba(16, 24, 40, .14);
    --sidebar-w: 266px;
    --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

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

/* ---- App shell ---- */
.app { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 22px;
    font-size: 22px;
    letter-spacing: .3px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: var(--grad);
    display: grid;
    place-items: center;
    font-size: 17px;
    color: #fff;
    box-shadow: 0 6px 16px rgba(22, 163, 74, .35);
}

.brand-text { font-weight: 400; color: var(--muted); }
.brand-text b { font-weight: 700; color: var(--text); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--muted);
    padding: 14px 12px 6px;
}

.nav-item, .nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 13px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 14.5px;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s, color .15s;
}

.nav-item i, .nav-group-toggle > i:first-child {
    width: 20px;
    text-align: center;
    font-size: 15px;
}

.nav-item:hover, .nav-group-toggle:hover {
    background: #f1f3f5;
    color: var(--text);
}

.nav-item.active {
    background: var(--grad);
    color: #fff;
    box-shadow: 0 8px 18px rgba(22, 163, 74, .3);
}

.nav-group-toggle .caret {
    margin-left: auto;
    font-size: 11px;
    transition: transform .25s;
}

.nav-group.open .caret { transform: rotate(180deg); }
.nav-group.open .nav-group-toggle { color: var(--text); }

.nav-group-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s ease;
    display: flex;
    flex-direction: column;
}

.nav-group.open .nav-group-menu { max-height: 340px; }

.nav-sub-item {
    padding: 9px 13px 9px 45px;
    font-size: 13.5px;
    color: var(--muted);
    border-radius: 9px;
    transition: background .15s, color .15s;
}

.nav-sub-item:hover { background: #f1f3f5; color: var(--text); }
.nav-sub-item.active { color: var(--accent); font-weight: 600; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 11px;
    border-radius: 10px;
    background: #fef2f2;
    color: var(--danger);
    font-weight: 600;
    font-size: 14px;
    border: 1px solid #f6d5d5;
    transition: background .15s;
}

.btn-logout:hover { background: #fde4e4; }

/* ---- Main area ---- */
.main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 26px;
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
}

.hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    width: 38px; height: 38px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
}

.page-title { font-size: 19px; font-weight: 600; }

.topbar-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 11px;
}

.user-meta { display: flex; flex-direction: column; text-align: right; line-height: 1.25; }
.user-name { font-size: 13.5px; font-weight: 600; }
.user-role { font-size: 11.5px; color: var(--muted); }

.user-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--grad);
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #fff;
}

.content { padding: 26px; }

/* ---- Cards ---- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow-sm);
}

.welcome-card {
    background: radial-gradient(120% 160% at 100% 0%, rgba(22, 163, 74, .1), transparent 60%), var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: var(--shadow-sm);
}

.welcome-card h2 { font-size: 23px; font-weight: 700; margin-bottom: 6px; }
.welcome-card p { color: var(--muted); font-size: 14px; }

.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .15s;
}

.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.stat-icon {
    width: 42px; height: 42px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 17px;
}

.stat-value { font-size: 27px; font-weight: 700; }
.stat-label { font-size: 13px; color: var(--muted); }

.i-green { background: #e8f6ee; color: #16a34a; }
.i-red   { background: #fdecec; color: #dc2626; }
.i-blue  { background: #e8f0fe; color: #2563eb; }
.i-amber { background: #fef3e2; color: #d97706; }

.section-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.muted { color: var(--muted); }

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

.qa-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    border-radius: 11px;
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 500;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.qa-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.qa-btn i { color: var(--accent); }

/* ---- Forms ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.form-label .req { color: var(--danger); }

.form-control {
    background: #f5f6f8;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 13px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    outline: none;
    width: 100%;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.form-control:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .15);
}

.form-control::placeholder { color: #a3a8b3; }
textarea.form-control { resize: vertical; min-height: 72px; }

.form-actions { display: flex; gap: 12px; margin-top: 22px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 22px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform .12s, box-shadow .15s, background .15s;
}

.btn-primary {
    background: var(--grad);
    color: #fff;
    box-shadow: 0 8px 20px rgba(22, 163, 74, .3);
}

.btn-primary:hover { transform: translateY(-1px); }

.btn-light {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.btn-light:hover { background: #f1f3f5; }

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    display: flex;
    gap: 9px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.alert i { margin-top: 2px; }
.alert-success { background: #e8f6ee; border: 1px solid #bfe6cc; color: #15803d; }
.alert-error { background: #fdecec; border: 1px solid #f6d5d5; color: #b91c1c; }

/* ---- Data table ---- */
.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th {
    text-align: left;
    padding: 11px 14px;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f7f8fa; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-locked { background: #fdecec; color: #b91c1c; }
.badge-active { background: #e8f6ee; color: #15803d; }

.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-state i { font-size: 34px; margin-bottom: 12px; color: #c7cbd3; }

/* ---- Small action button ---- */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    background: var(--accent-soft);
    color: var(--accent-dark);
    border: 1px solid #bfe6cc;
    white-space: nowrap;
    transition: background .15s;
}

.btn-action:hover { background: #d6efdf; }

/* ---- Search bar ---- */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; }
.search-bar .form-control { max-width: 340px; }

/* ---- Info grid (detail view) ---- */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px 24px;
}

.info-item { display: flex; flex-direction: column; gap: 4px; }

.info-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--muted);
    font-weight: 600;
}

.info-value { font-size: 14.5px; font-weight: 500; word-break: break-word; }

.placeholder-box {
    border: 1px dashed #cdd2da;
    border-radius: 12px;
    padding: 26px;
    text-align: center;
    color: var(--muted);
    font-size: 13.5px;
}

/* ---- Device control buttons ---- */
.ctrl-group { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }

.ctrl-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 18px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    transition: background .15s, border-color .15s, transform .12s;
}

.ctrl-btn:hover { transform: translateY(-1px); border-color: #cdd2da; }
.ctrl-btn i { font-size: 14px; }

.ctrl-danger { background: #fdecec; color: #b91c1c; border-color: #f6d5d5; }
.ctrl-danger:hover { background: #fbdcdc; }
.ctrl-ok { background: var(--accent-soft); color: var(--accent-dark); border-color: #bfe6cc; }
.ctrl-ok:hover { background: #d6efdf; }

.ctrl-label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 6px 0 8px; }

.alert-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.alert-form .form-control { max-width: 340px; }

/* ---- Auth / Login ---- */
.auth-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: radial-gradient(58% 48% at 50% 0%, rgba(22, 163, 74, .14), transparent 70%), var(--bg);
}

.auth-wrap { width: 100%; max-width: 410px; }

.auth-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 38px 34px;
    box-shadow: var(--shadow-lg);
}

.auth-brand { display: flex; justify-content: center; margin-bottom: 18px; }
.auth-brand .brand-mark { width: 52px; height: 52px; border-radius: 15px; font-size: 22px; }

.auth-title { text-align: center; font-size: 30px; font-weight: 700; letter-spacing: .3px; }
.auth-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 7px 0 24px; }

.auth-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    margin: 14px 0 7px;
}

.auth-input {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f6f8;
    border: 1px solid var(--border);
    border-radius: 11px;
    padding: 0 13px;
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.auth-input:focus-within {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, .15);
}

.auth-input i { color: var(--muted); font-size: 14px; }

.auth-input input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 14.5px;
    padding: 13px 0;
}

.auth-input input::placeholder { color: #a3a8b3; }

.pwd-toggle {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
}

.auth-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 16px 0;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
}

.auth-remember input { accent-color: var(--accent); width: 15px; height: 15px; }

.auth-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 11px;
    background: var(--grad);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: .3px;
    box-shadow: 0 10px 24px rgba(22, 163, 74, .32);
    transition: transform .12s, box-shadow .15s;
}

.auth-btn:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(22, 163, 74, .42); }
.auth-btn:active { transform: translateY(0); }

.auth-alert {
    background: #fdecec;
    border: 1px solid #f6d5d5;
    color: #b91c1c;
    padding: 11px 13px;
    border-radius: 10px;
    font-size: 13.5px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 6px;
}

.auth-foot { text-align: center; color: #9aa0ac; font-size: 12px; margin-top: 22px; }

/* ---- Mobile sidebar overlay ---- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 24, 40, .4);
    z-index: 40;
}

.sidebar-overlay.show { display: block; }

/* ---- Responsive ---- */
@media (max-width: 880px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburger { display: grid; place-items: center; }
}

@media (max-width: 620px) {
    .form-grid { grid-template-columns: 1fr; }
}
