* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
}

nav {
    background: #1a1a2e;
    color: #fff;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: 56px;
    gap: 2rem;
}

.nav-brand {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-links { display: flex; gap: 1rem; }
.nav-links a { color: #ccc; text-decoration: none; font-size: 0.9rem; }
.nav-links a:hover { color: #fff; }

main { max-width: 960px; margin: 2rem auto; padding: 0 1rem; }

h1 { margin-bottom: 1rem; font-size: 1.5rem; }
h2 { margin: 1.5rem 0 0.75rem; font-size: 1.2rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-value { font-size: 2rem; font-weight: 700; color: #1a1a2e; }
.stat-label { font-size: 0.85rem; color: #666; margin-top: 0.25rem; }

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-top: 1rem;
}

th, td { padding: 0.75rem 1rem; text-align: left; }
th { background: #f8f9fa; font-size: 0.85rem; color: #666; font-weight: 600; border-bottom: 2px solid #e9ecef; }
td { border-bottom: 1px solid #f0f0f0; font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }

.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

input[type="text"], input[type="number"], select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    background: #1a1a2e;
    color: #fff;
}

.btn:hover { opacity: 0.9; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-danger { background: #dc3545; }
.btn-success { background: #28a745; }

.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
    background: #e9ecef;
    color: #666;
}

.badge-block { background: #f8d7da; color: #721c24; border: 2px solid #721c24; cursor: pointer; }
.badge-block:hover { background: #f1aeb5; }
.badge-allow { background: #d4edda; color: #155724; border: 2px solid #155724; cursor: pointer; }
.badge-allow:hover { background: #b7dfca; }
.badge-off { background: #e9ecef; color: #666; border: 2px solid #adb5bd; cursor: pointer; }
.badge-off:hover { background: #d8dde2; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-approved { background: #d4edda; color: #155724; }
.badge-denied { background: #f8d7da; color: #721c24; }

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
    vertical-align: middle;
}
.status-online { background: #28a745; box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2); }
.status-offline { background: #adb5bd; }

.alert { padding: 1rem; border-radius: 8px; margin: 1rem 0; }
.alert-success { background: #d4edda; border: 1px solid #c3e6cb; }

.app-footer {
    text-align: center;
    padding: 1rem;
    color: #aaa;
    font-size: 0.75rem;
}

/* Setup page */
.setup-page { max-width: 640px; }

.setup-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.setup-step {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
}

.setup-step + .setup-step { border-top: 1px solid #f0f0f0; }

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    background: #1a1a2e;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.step-content { flex: 1; min-width: 0; }
.step-content h3 { font-size: 1rem; margin-bottom: 0.5rem; }
.step-content p { font-size: 0.9rem; color: #555; margin-bottom: 0.75rem; }

.btn-download {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    text-decoration: none;
}

.cmd-block {
    position: relative;
    background: #1a1a2e;
    border-radius: 6px;
    padding: 1rem;
    margin: 0.5rem 0;
    overflow-x: auto;
}

.cmd-block code {
    color: #e0e0e0;
    font-size: 0.8rem;
    font-family: "SF Mono", "Fira Code", monospace;
    white-space: pre;
    display: block;
    padding-right: 3.5rem;
}

.btn-copy {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255,255,255,0.15);
    color: #ccc;
    border: none;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-copy:hover { background: rgba(255,255,255,0.25); color: #fff; }

.hint { font-size: 0.8rem; color: #888; }
.hint code { font-size: 0.8rem; color: #666; }

.rule-actions { white-space: nowrap; display: flex; gap: 0.35rem; align-items: center; }
.schedule-count { color: #aaa; font-size: 0.8rem; margin-left: 0.15rem; }

.schedule-dialog {
    border: none;
    border-radius: 12px;
    padding: 0;
    width: min(380px, calc(100vw - 2rem));
    margin: 12vh auto auto;
    box-shadow: 0 24px 60px rgba(20, 20, 50, 0.28);
    background: #fff;
    color: #333;
    overflow: hidden;
}
.schedule-dialog[open] { animation: schedule-pop 140ms ease-out; }
.schedule-dialog::backdrop {
    background: rgba(15, 15, 30, 0.45);
    backdrop-filter: blur(2px);
}
@keyframes schedule-pop {
    from { opacity: 0; transform: translateY(-6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.schedule-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem 0.9rem;
    border-bottom: 1px solid #f0f0f0;
}
.schedule-modal-header h2 { font-size: 1rem; margin: 0; line-height: 1.2; }
.schedule-modal-sub { font-size: 0.8rem; color: #888; margin-top: 0.2rem; }
.schedule-modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: #aaa;
    cursor: pointer;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    margin: -0.25rem -0.4rem 0 0;
}
.schedule-modal-close:hover { color: #333; background: #f3f3f5; }

.schedule-list {
    list-style: none;
    padding: 0.35rem 0;
    margin: 0;
    max-height: 280px;
    overflow-y: auto;
}
.schedule-item {
    display: grid;
    grid-template-columns: 64px 1fr 32px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.25rem;
}
.schedule-item + .schedule-item { border-top: 1px solid #f5f5f5; }
.schedule-item .schedule-time {
    font-family: "SF Mono", "Fira Code", monospace;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}
.schedule-item .badge {
    justify-self: start;
    min-width: 64px;
    text-align: center;
}
.schedule-item-delete {
    justify-self: end;
    background: none;
    border: none;
    color: #c33;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.schedule-item-delete:hover { background: #fbeaea; }
.schedule-empty {
    padding: 1.25rem;
    color: #aaa;
    font-size: 0.85rem;
    text-align: center;
}

.schedule-add-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.85rem 1.25rem;
    background: #f8f9fa;
    border-top: 1px solid #f0f0f0;
}
.schedule-add-form > select {
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
    min-width: 0;
    width: 100%;
}
.schedule-add-form button { white-space: nowrap; }

.time-picker {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0;
    font-family: "SF Mono", "Fira Code", monospace;
    font-weight: 600;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.time-picker:hover { border-color: #b8b8c4; }
.time-picker:focus-within {
    border-color: #1a1a2e;
    box-shadow: 0 0 0 3px rgba(26, 26, 46, 0.12);
}
.time-picker select {
    border: none;
    background: transparent;
    padding: 0.5rem 0.6rem;
    font-family: inherit;
    font-weight: inherit;
    font-size: 0.95rem;
    text-align: center;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    color: #1a1a2e;
}
.time-picker select:focus { outline: none; background: #f4f4f8; border-radius: 4px; }
.time-sep {
    color: #999;
    font-size: 1rem;
    line-height: 1;
    user-select: none;
    padding: 0 0.05rem;
}

@media (max-width: 480px) {
    .schedule-dialog { margin: 8vh auto auto; }
}

.setup-extra {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
    overflow: hidden;
}

.setup-extra summary {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: #555;
    font-weight: 600;
}

.setup-extra summary:hover { background: #f8f9fa; }

.setup-extra > p,
.setup-extra > .cmd-block {
    margin-left: 1.5rem;
    margin-right: 1.5rem;
}

.setup-extra > p { font-size: 0.9rem; color: #555; }
.setup-extra > p:last-child,
.setup-extra > .cmd-block:last-child { margin-bottom: 1rem; }

.token {
    display: block;
    padding: 0.75rem;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin: 0.5rem 0;
    word-break: break-all;
    font-size: 0.85rem;
}
