* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Microsoft YaHei", Arial, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
}

a {
    color: inherit;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    background: #111827;
    color: #fff;
}

.topbar-inner {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    text-decoration: none;
    font-weight: 700;
    font-size: 18px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.nav a {
    text-decoration: none;
}

.nav-user {
    opacity: .7;
}

.main {
    padding: 28px 0 50px;
}

.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.card h1,
.card h2,
.card h3 {
    margin-top: 0;
}

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

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

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
}

th {
    background: #f9fafb;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 7px;
    background: #fff;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

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

.form-help {
    color: #6b7280;
    font-size: 13px;
    margin-top: 5px;
}

.btn {
    display: inline-block;
    padding: 9px 14px;
    border: 0;
    border-radius: 7px;
    background: #2563eb;
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.btn-secondary {
    background: #4b5563;
}

.btn-danger {
    background: #dc2626;
}

.btn-success {
    background: #059669;
}

.btn-small {
    padding: 6px 10px;
    font-size: 13px;
}

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

.inline-form {
    display: inline;
}

.alert {
    padding: 12px 14px;
    border-radius: 7px;
    margin-bottom: 18px;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: #e5e7eb;
}

.badge-ok {
    background: #d1fae5;
    color: #065f46;
}

.badge-off {
    background: #fee2e2;
    color: #991b1b;
}

.login-box {
    width: min(420px, 100%);
    margin: 70px auto;
}

.device-title {
    font-size: 18px;
    font-weight: 700;
}

.muted {
    color: #6b7280;
}

.footer {
    padding: 24px 0;
    color: #9ca3af;
    text-align: center;
}

.permission-item {
    display: grid;
    grid-template-columns: 38px minmax(220px, 1fr) minmax(250px, 320px);
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

@media (max-width: 760px) {
    .topbar-inner,
    .nav {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-inner {
        padding: 14px 0;
    }

    .permission-item {
        grid-template-columns: 32px 1fr;
    }

    .permission-item .expiry {
        grid-column: 2;
    }
}
