:root {
    --bg: #0f172a;
    --card: #ffffff;
    --muted: #64748b;
    --line: #e2e8f0;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --danger: #dc2626;
    --ok: #16a34a;
    --text: #0f172a;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--text);
    background: #f1f5f9;
    line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Top bar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 58px;
    background: var(--bg);
    color: #fff;
}
.topbar .brand { color: #fff; font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 32px; width: auto; display: block; background: #fff; border-radius: 7px; padding: 3px 8px; }
.auth-logo { max-height: 56px; max-width: 100%; display: block; margin: 0 auto 12px; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { color: #cbd5e1; }
.topbar nav a:hover { color: #fff; text-decoration: none; }
.topbar .who { color: #94a3b8; font-size: 14px; }
.btn-link { color: #fff !important; }

/* ---- Layout ---- */
.container { max-width: 1180px; margin: 0 auto; padding: 28px 20px; }
.foot { text-align: center; color: var(--muted); padding: 32px; font-size: 13px; }

h1 { font-size: 24px; margin: 0 0 8px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }

/* ---- Auth card ---- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.auth-card {
    background: var(--card);
    width: 100%;
    max-width: 380px;
    padding: 32px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}
.auth-card h1 { text-align: center; }
.auth-card .subtitle { text-align: center; }

/* ---- Forms ---- */
label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 15px;
    background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.checkbox { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-weight: 500; }
.checkbox input { width: auto; }
.checkbox label { margin: 0; font-weight: 500; }

.btn {
    display: inline-block;
    width: 100%;
    margin-top: 20px;
    padding: 11px 16px;
    background: var(--brand);
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { background: var(--brand-dark); }
.btn.secondary { background: #e2e8f0; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.small { width: auto; margin: 0; padding: 7px 12px; font-size: 13px; }

.row-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 14px; }

/* ---- Messages ---- */
.flash, .error, .success {
    padding: 12px 14px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
}
.flash   { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ---- App grid ---- */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
    margin-top: 8px;
}
.app-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 22px;
    transition: transform .08s ease, box-shadow .08s ease;
}
.app-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15,23,42,.10); text-decoration: none; }
.app-tile .icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; color: #fff;
    background: var(--brand);
    margin-bottom: 14px;
}
.app-tile .icon-img { background: #f1f5f9; padding: 0; overflow: hidden; }
.app-tile .icon-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.app-tile .app-name { font-weight: 700; color: var(--text); }
.app-tile .app-desc { color: var(--muted); font-size: 13px; margin-top: 4px; }
.empty { color: var(--muted); background:#fff; border:1px dashed var(--line); padding:32px; border-radius:12px; text-align:center; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; background:#fff; border-radius:10px; overflow:hidden; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { background: #f8fafc; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:last-child td { border-bottom: 0; }
.badge { display:inline-block; padding:2px 8px; border-radius:999px; font-size:12px; font-weight:600; }
.badge.admin { background:#ede9fe; color:#6d28d9; }
.badge.off   { background:#fee2e2; color:#991b1b; }
.badge.on    { background:#dcfce7; color:#166534; }

.actions { display:flex; gap:8px; flex-wrap:wrap; }
.app-thumb { width:36px; height:36px; border-radius:8px; object-fit:contain; background:#f1f5f9; display:flex; align-items:center; justify-content:center; }
.app-thumb.letter { color:#fff; background:var(--brand); font-weight:700; font-size:15px; }
.page-head { display:flex; align-items:center; justify-content:space-between; margin-bottom:20px; }
.checks { display:grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap:8px; margin-top:6px; }
.checks label { font-weight:500; display:flex; gap:8px; align-items:center; margin:0; }
.checks input { width:auto; }

/* ---- Settings ---- */
.card { background:#fff; padding:24px; border:1px solid var(--line); border-radius:12px; }
.color-row { display:flex; align-items:center; gap:14px; margin-top:8px; }
.color-row input[type=color] { width:52px; height:40px; padding:2px; border:1px solid var(--line); border-radius:8px; cursor:pointer; }
.color-row input[type=text] { width:130px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.swatch-grid { display:flex; gap:10px; flex-wrap:wrap; margin-top:10px; }
.swatch { width:30px; height:30px; border-radius:8px; border:0; cursor:pointer; }
.logo-current { display:flex; align-items:center; gap:16px; margin-top:8px; }
.logo-current img { max-height:48px; max-width:200px; background:#f1f5f9; padding:6px 10px; border-radius:8px; }
.preview-bar { height:48px; border-radius:8px; display:flex; align-items:center; padding:0 16px; color:#fff; font-weight:700; margin-top:8px; }

/* ---- Notifications bell ---- */
.topbar nav { position: relative; }
.notif-bell { position:relative; background:transparent; border:0; color:#cbd5e1; font-size:16px; cursor:pointer; padding:2px 4px; }
.notif-bell:hover { color:#fff; }
.notif-badge { position:absolute; top:-6px; right:-8px; background:var(--danger); color:#fff; font-size:10px; font-weight:700; min-width:16px; height:16px; line-height:16px; text-align:center; border-radius:999px; padding:0 4px; }
.notif-panel { position:absolute; top:46px; right:90px; width:300px; max-height:380px; overflow:auto; background:#fff; border:1px solid var(--line); border-radius:10px; box-shadow:0 10px 30px rgba(15,23,42,.18); z-index:60; padding:6px; }
.notif-item { font-size:13px; color:var(--text); padding:9px 10px; border-bottom:1px solid var(--line); }
.notif-item:last-of-type { border-bottom:0; }
.notif-time { display:block; font-size:11px; color:var(--muted); margin-top:2px; }
.notif-empty { font-size:13px; color:var(--muted); padding:14px; text-align:center; }
.notif-clear { width:100%; margin-top:4px; background:#f1f5f9; border:0; border-radius:8px; padding:8px; font-size:12px; font-weight:600; cursor:pointer; color:var(--text); }

/* ---- Tasks ---- */
.task-widget { margin-top:28px; }
.task-table { width:100%; border-collapse:collapse; background:#fff; border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.task-table th { text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); background:#f8fafc; padding:9px 12px; border-bottom:1px solid var(--line); }
.task-table td { padding:10px 12px; border-bottom:1px solid var(--line); font-size:14px; vertical-align:top; }
.task-table tr:last-child td { border-bottom:0; }
.task-table tr.task-done td { opacity:.55; }
.rag { display:inline-block; width:12px; height:12px; border-radius:50%; background:var(--muted); }
.rag-red { background:#dc2626; } .rag-amber { background:#f59e0b; } .rag-green { background:#16a34a; }
.rag-done { background:#94a3b8; } .rag-none { background:#cbd5e1; }
.pri { font-size:11px; font-weight:700; text-transform:uppercase; padding:2px 8px; border-radius:999px; }
.pri-low { background:#eef2ff; color:#4f46e5; } .pri-normal { background:#f1f5f9; color:#475569; } .pri-high { background:#fef2f2; color:#b91c1c; }
.st { font-size:11px; font-weight:700; padding:2px 8px; border-radius:999px; }
.st-open { background:#eff6ff; color:#1e40af; } .st-in_progress { background:#fffbeb; color:#92400e; } .st-done { background:#f0fdf4; color:#166534; }

/* ---- Task modal ---- */
.tm-ov { position:fixed; inset:0; background:rgba(15,23,42,.5); z-index:80; display:flex; align-items:flex-start; justify-content:center; padding:40px 16px; overflow:auto; }
.tm-box { background:#fff; width:100%; max-width:520px; border-radius:14px; box-shadow:0 10px 30px rgba(15,23,42,.2); overflow:hidden; }
.tm-h { display:flex; align-items:center; justify-content:space-between; padding:14px 18px; background:var(--bg); color:#fff; }
.tm-x { background:none; border:0; color:#cbd5e1; font-size:16px; cursor:pointer; }
.tm-b { padding:16px 18px; }
.tm-b label { display:block; font-size:12px; font-weight:600; color:var(--muted); margin:10px 0 4px; }
.tm-b input, .tm-b textarea, .tm-b select { width:100%; border:1px solid var(--line); border-radius:8px; padding:8px 10px; font-size:14px; font-family:inherit; }
.tm-row { display:flex; gap:12px; }
.tm-f { display:flex; justify-content:flex-end; gap:10px; padding:13px 18px; border-top:1px solid var(--line); background:#f8fafc; }
.actions select { border:1px solid var(--line); border-radius:8px; padding:7px 10px; font-size:13px; }
