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

:root {
    --primary: #0f766e;
    --primary-dark: #115e59;
    --primary-light: #f0fdfa;
    --word-blue: #1d4ed8;
    --word-blue-hover: #1e40af;
    --bg-app: #f1f5f9;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #cbd5e1;
    --white: #ffffff;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
}

/* LOGIN SCREEN */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f766e 0%, #064e3b 100%);
    padding: 20px;
}

.login-card {
    background: var(--white);
    width: 100%;
    max-width: 430px;
    padding: 36px 32px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    text-align: center;
}

.login-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-card h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.35;
}

.login-card h1 span {
    color: var(--primary);
    font-size: 22px;
}

.login-subtitle {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 10px 0 24px;
}

.login-form {
    text-align: left;
}

.login-footer {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
    font-size: 12.5px;
    color: var(--text-muted);
}

.alert-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 16px;
}

/* TOPBAR */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo-badge {
    background: var(--primary);
    color: var(--white);
    font-weight: 700;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

.app-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
}

.app-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.status-pill {
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
}

.status-ok {
    background: #dcfce7;
    color: #166534;
}

.status-warn {
    background: #fef3c7;
    color: #92400e;
    cursor: pointer;
}

/* WORKSPACE LAYOUT */
.workspace {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    padding: 20px 24px;
    max-width: 1600px;
    margin: 0 auto;
    align-items: start;
}

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

.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
    overflow: hidden;
}

.card-header {
    background: #f8fafc;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary-dark);
}

.card-body {
    padding: 18px;
}

/* FORMS & INPUTS */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #334155;
}

.req {
    color: #dc2626;
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-main);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* GRADE SELECTOR */
.grade-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.grade-option {
    cursor: pointer;
    margin: 0 !important;
}

.grade-option input {
    display: none;
}

.grade-option span {
    display: block;
    text-align: center;
    padding: 10px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    background: #f8fafc;
    transition: all 0.2s;
}

.grade-option input:checked + span {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    box-shadow: 0 2px 4px rgba(15, 118, 110, 0.12);
}

/* QUICK TAGS */
.quick-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.tag-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    font-size: 11.5px;
    font-weight: 500;
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.tag-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
}

/* DETAILS */
.admin-details {
    margin-bottom: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    background: #f8fafc;
}

.admin-details summary {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary-dark);
    cursor: pointer;
    user-select: none;
}

.details-content {
    margin-top: 12px;
}

/* BUTTONS */
.btn-primary {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-large {
    padding: 13px 20px;
    font-size: 15px;
}

.btn-full {
    width: 100%;
}

.btn-secondary {
    background: var(--white);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.btn-secondary:hover:not(:disabled) {
    background: #f1f5f9;
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-word {
    background: var(--word-blue);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 6px rgba(29, 78, 216, 0.25);
}

.btn-word:hover:not(:disabled) {
    background: var(--word-blue-hover);
}

.btn-word:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 7px 13px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-outline:hover {
    background: #f8fafc;
}

.btn-danger-outline {
    text-decoration: none;
    color: #dc2626;
    border: 1px solid #fecaca;
    background: #fef2f2;
    padding: 7px 13px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

.btn-danger-outline:hover {
    background: #fee2e2;
}

/* RIGHT PANEL & A4 PREVIEW */
.panel-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preview-toolbar {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-title {
    font-weight: 700;
    font-size: 14.5px;
    color: var(--text-main);
}

.edit-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* LOADING BOX */
.loading-box {
    background: var(--white);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 28px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ccfbf1;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 14px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-box h3 {
    font-size: 16px;
    color: var(--primary-dark);
    margin-bottom: 6px;
}

.loading-box p {
    font-size: 13.5px;
    color: var(--text-muted);
}

/* A4 PAPER VIEWPORT */
.a4-viewport {
    background: #cbd5e1;
    border-radius: 12px;
    padding: 24px;
    overflow-x: auto;
    max-height: calc(100vh - 150px);
    overflow-y: auto;
}

.a4-page {
    background: #ffffff;
    width: 210mm;
    min-height: 297mm;
    margin: 0 auto;
    padding: 20mm 15mm 20mm 25mm;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    font-family: "Times New Roman", Times, serif;
    font-size: 13pt;
    line-height: 1.45;
    color: #000000;
}

.a4-page[contenteditable="true"] {
    outline: 2px dashed var(--primary);
}

/* TYPOGRAPHY INSIDE A4 LESSON PLAN */
.a4-page h1, .a4-page h2, .a4-page h3, .a4-page h4 {
    font-family: "Times New Roman", Times, serif;
    color: #000000;
    margin-top: 10pt;
    margin-bottom: 5pt;
}

.a4-page h2 {
    font-size: 14pt;
    font-weight: bold;
    text-transform: uppercase;
}

.a4-page h3 {
    font-size: 13pt;
    font-weight: bold;
}

.a4-page h4 {
    font-size: 13pt;
    font-weight: bold;
}

.a4-page p {
    margin-bottom: 5pt;
    text-align: justify;
}

.a4-page ul, .a4-page ol {
    margin-left: 22pt;
    margin-bottom: 6pt;
}

.a4-page li {
    margin-bottom: 3pt;
    text-align: justify;
}

.a4-page table {
    width: 100%;
    border-collapse: collapse;
    margin: 8pt 0;
    font-size: 12.5pt;
}

.a4-page table.data-table th,
.a4-page table.data-table td,
.a4-page table:not(.header-table):not(.sign-table) th,
.a4-page table:not(.header-table):not(.sign-table) td {
    border: 1px solid #000000;
    padding: 6pt 8pt;
    vertical-align: top;
}

.a4-page table.header-table td,
.a4-page table.sign-table td {
    border: none;
    padding: 3pt 4pt;
    vertical-align: top;
}

.a4-page table.sign-table td {
    text-align: center;
    font-weight: bold;
    padding-top: 14pt;
}

/* EMPTY STATE */
.empty-state {
    font-family: 'Inter', sans-serif;
    text-align: center;
    padding: 90px 30px;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-family: 'Inter', sans-serif;
    font-size: 19px;
    color: var(--text-main);
    margin-bottom: 10px;
}

.empty-state p {
    font-family: 'Inter', sans-serif;
    font-size: 14.5px;
    text-align: center;
    max-width: 520px;
    margin: 0 auto 10px;
}

.empty-hint {
    font-size: 13px !important;
    color: var(--primary-dark);
}

/* MODAL */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.modal-box {
    background: var(--white);
    width: 100%;
    max-width: 720px;
    border-radius: 14px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 16px 20px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-close {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 14px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.help-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-muted);
}

.hidden {
    display: none !important;
}
