:root {
    --bg: #ffffff;
    --panel: #ffffff;
    --text: #111827;
    --muted: #64748b;
    --line: #dbe7f5;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --normal: #38bdf8;
    --medium: #2563eb;
    --high: #1e3a8a;
    --soft: #eff6ff;
    --shadow: 0 12px 34px rgba(37, 99, 235, .08);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    font-family: "Tajawal", "Beiruti", "Zain", Arial, sans-serif;
    color: var(--text);
    background: #fff;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
select {
    cursor: pointer;
}

.app-shell {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    padding: 22px 0 40px;
}

.topbar,
.panel-title,
.top-actions,
.actions,
.form-actions,
.tabs,
.legend {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar {
    justify-content: space-between;
    margin-bottom: 16px;
}

h1,
h2,
p {
    letter-spacing: 0;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 34px;
}

h2 {
    font-size: 20px;
}

.status-pill,
.hint {
    color: var(--muted);
    font-size: 13px;
}

.status-pill {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--panel);
    padding: 7px 10px;
}

.auth-layout {
    min-height: 76vh;
    display: grid;
    justify-content: center;
    align-items: start;
    padding-top: 12px;
    background: #fff;
}

.login-panel {
    width: 506px;
    max-width: 100%;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0;
}

.auth-heading {
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 16px;
    margin-bottom: 34px;
}

.auth-brand {
    flex: 0 0 auto;
    display: inline-flex;
    line-height: 0;
}

.auth-brand img {
    display: block;
    width: 82px;
    height: auto;
    object-fit: contain;
}

.auth-copy {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
}

.auth-title {
    font-size: 34px;
    line-height: 1.15;
}

.login-panel p,
.auth-copy p {
    margin: 0 0 18px;
    color: var(--muted);
}

.auth-copy p {
    margin: 8px 0 0;
}

.auth-modes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 16px 0;
}

.google-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    margin-top: 10px;
    min-height: 48px;
    padding: 12px 14px;
    text-align: center;
    text-decoration: none;
    font-weight: 700;
    font-size: 18px;
}

.google-icon {
    width: 19px;
    height: 19px;
    flex: 0 0 auto;
}

.google-button.disabled {
    opacity: .72;
}

.auth-divider {
    height: 1px;
    background: var(--line);
    margin: 28px 0 20px;
}

.login-panel label {
    display: block;
    width: 100%;
    margin-bottom: 14px;
}

.login-panel input {
    display: block;
    width: 100%;
    min-height: 64px;
    border-radius: 8px;
    font-size: 16px;
    padding: 21px 14px 10px;
}

.login-panel .primary {
    width: 100%;
    min-height: 50px;
    margin-top: 2px;
    font-weight: 700;
    font-size: 18px;
}

.auth-link {
    border: 0;
    background: transparent;
    color: var(--accent-dark);
    padding: 12px 0 0;
    text-decoration: underline;
}

.auth-link.inline {
    display: inline;
    padding: 0;
}

.auth-footer {
    border-top: 1px solid var(--line);
    margin: 18px 0 0;
    padding-top: 18px;
    text-align: center;
    color: var(--text);
}

.panel,
.metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.panel {
    padding: 18px;
}

.tabs {
    margin-bottom: 14px;
    overflow-x: auto;
}

.tab,
.ghost,
.actions button,
.import-button {
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    padding: 10px 13px;
    white-space: nowrap;
}

.tab.active,
.primary {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}

.ghost {
    color: var(--accent-dark);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.metric {
    padding: 15px;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 8px;
}

.metric strong {
    font-size: 25px;
    line-height: 1.2;
}

.alerts {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.alert {
    border-radius: 8px;
    padding: 12px 14px;
    border: 1px solid;
    background: #fff;
}

.alert.high {
    border-color: #bfdbfe;
    color: var(--high);
    background: #eff6ff;
}

.alert.medium {
    border-color: #dbeafe;
    color: var(--medium);
    background: #f8fbff;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    gap: 14px;
}

.quick-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 14px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.section-block {
    margin-top: 14px;
}

.section-block:first-child {
    margin-top: 0;
}

.section-title {
    margin: 0 0 10px;
}

.wide {
    grid-column: 1 / -1;
}

label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    padding: 10px 11px;
}

textarea {
    resize: vertical;
}

.primary {
    border-radius: 7px;
    padding: 10px 14px;
}

.panel-title {
    justify-content: space-between;
    margin-bottom: 14px;
}

.reading-list {
    display: grid;
    gap: 9px;
}

.reading-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}

.badge {
    min-width: 86px;
    text-align: center;
    border-radius: 999px;
    padding: 7px 9px;
    color: #fff;
    font-weight: 700;
}

.badge.normal,
.dot.normal {
    background: var(--normal);
}

.badge.medium,
.dot.medium {
    background: var(--medium);
}

.badge.high,
.dot.high {
    background: var(--high);
}

.legend {
    flex-wrap: wrap;
    color: var(--muted);
    margin-bottom: 12px;
}

.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 5px;
}

.chart-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 300px;
}

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

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    text-align: right;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 13px;
}

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

.link-btn {
    border: 0;
    background: transparent;
    color: var(--accent-dark);
    padding: 0;
}

.link-btn.danger {
    color: var(--high);
}

.import-button {
    position: relative;
    overflow: hidden;
}

.import-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
}

.empty {
    color: var(--muted);
}

@media (max-width: 860px) {
    .topbar,
    .panel-title {
        align-items: stretch;
        flex-direction: column;
    }

    .summary-grid,
    .workspace,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .quick-form {
        grid-template-columns: 1fr;
    }

    .auth-modes {
        grid-template-columns: 1fr;
    }

    .wide {
        grid-column: auto;
    }
}

@media (max-width: 560px) {
    .app-shell {
        width: min(100% - 18px, 1180px);
        padding-top: 14px;
    }

    h1 {
        font-size: 28px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .top-actions,
    .actions {
        flex-wrap: wrap;
    }
}
