/* RESET */
* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

/* THEME */
:root {
    --purple-950: #2c0d50;
    --purple-900: #3d0f6e;
    --purple-800: #4f148a;
    --purple-700: #6720ab;
    --purple-600: #7d33c0;
    --gold-600: #c9991f;
    --gold-500: #d9ad37;
    --gold-400: #edc968;
    --white: #ffffff;
    --surface: #ffffff;
    --surface-2: #fbf8ff;
    --text: #1f1730;
    --muted: #6d6088;
    --border: #ddcff4;
    --border-strong: #ccb6ef;
    --success-bg: #eef9f0;
    --success-border: #bcdfc3;
    --success-text: #227343;
    --error-bg: #fff0f0;
    --error-border: #efc2c2;
    --error-text: #a02d2d;
    --shadow-soft: 0 10px 24px rgba(48, 15, 83, 0.08);
    --shadow-card: 0 16px 34px rgba(52, 18, 89, 0.10);
    --radius-card: 18px;
    --radius-control: 12px;
}

/* BODY */
body {
    background:
        radial-gradient(circle at top right, rgba(121, 51, 192, 0.08), transparent 24%),
        linear-gradient(180deg, #faf7ff 0%, #f5f1fb 55%, #f1ebfb 100%);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.45;
}

/* LINKS */
a {
    color: var(--purple-800);
    text-decoration: none;
}

a:hover {
    text-decoration: none;
}

/* HEADER */
.site-header {
    background: linear-gradient(135deg, var(--purple-950), var(--purple-700));
    border-bottom: 2px solid rgba(237, 201, 104, 0.65);
    box-shadow: 0 10px 30px rgba(29, 7, 49, 0.22);
}

.header-inner {
    width: min(1280px, calc(100% - 40px));
    margin: 0 auto;
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 14px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 18px;
    color: var(--white);
    text-decoration: none;
    min-width: 0;
}

.brand:hover {
    text-decoration: none;
}

.brand img {
    height: 160px;
    width: auto;
    display: block;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.18));
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.brand-title {
    font-size: 32px;
    line-height: 1;
    font-weight: 800;
    color: var(--white);
    letter-spacing: 0.2px;
}

.brand-subtitle {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.84);
    letter-spacing: 0.2px;
}

.site-nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.site-nav a {
    color: rgba(255, 255, 255, 0.96);
    font-weight: 700;
    padding: 10px 14px;
    border-radius: 999px;
    line-height: 1;
    transition: background 0.18s ease, transform 0.18s ease, color 0.18s ease;
    white-space: nowrap;
}

.site-nav a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff6da;
    transform: translateY(-1px);
}

/* PAGE SHELL */
.page-shell {
    width: min(1280px, calc(100% - 40px));
    margin: 30px auto 36px;
    flex: 1;
}

.page-shell > * + * {
    margin-top: 20px;
}

/* CARDS */
.card {
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-card);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.flash {
    margin-bottom: 20px;
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 700;
    box-shadow: var(--shadow-soft);
}

.flash-success {
    background: var(--success-bg);
    border: 1px solid var(--success-border);
    color: var(--success-text);
}

.flash-error {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    color: var(--error-text);
}

/* LOGIN */
.login-page {
    min-height: calc(100vh - 190px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    width: min(500px, 100%);
    background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 34px;
    box-shadow: 0 22px 48px rgba(61, 19, 104, 0.14);
}

.login-logo {
    text-align: center;
    margin-bottom: 22px;
}

.login-logo img {
    max-width: 240px;
    width: 100%;
    height: auto;
}

.login-title {
    margin: 0 0 10px;
    text-align: center;
    font-size: 32px;
    color: var(--purple-900);
}

.login-subtitle {
    margin: 0 0 26px;
    text-align: center;
    color: var(--muted);
}

/* FORMS */
form {
    max-width: 100%;
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

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

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

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--purple-900);
    line-height: 1.35;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="date"],
input[type="time"],
input[type="number"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    min-height: 44px;
    padding: 12px 14px;
    border-radius: var(--radius-control);
    border: 1px solid var(--border-strong);
    background: var(--white);
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    border-color: var(--purple-600);
    box-shadow: 0 0 0 4px rgba(125, 51, 192, 0.12);
}

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

/* BUTTONS */
button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 18px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--gold-600), var(--gold-400));
    color: #2f2200;
    font-weight: 800;
    letter-spacing: 0.15px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 10px 22px rgba(201, 153, 31, 0.22);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    line-height: 1.1;
    white-space: nowrap;
    vertical-align: middle;
}

button:hover,
.button:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(201, 153, 31, 0.26);
}

.button-secondary {
    background: linear-gradient(135deg, var(--purple-800), var(--purple-600));
    color: var(--white);
    box-shadow: 0 10px 22px rgba(79, 20, 138, 0.20);
}

.inline-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 14px;
}

.inline-actions form {
    margin: 0;
}

.inline-actions > * {
    flex: 0 0 auto;
}

/* EXTRA HARDENING FOR FORMS WITH BUTTONS RIGHT AFTER TEXT */
.card .inline-actions,
form .inline-actions {
    row-gap: 10px;
}

.card .button,
.card button {
    margin-right: 0;
}

/* DASHBOARD */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.metric-card {
    min-height: 154px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.metric-card h3 {
    margin: 0 0 12px;
    color: var(--purple-900);
    font-size: 19px;
    line-height: 1.25;
}

.metric-card p {
    margin: 0;
    color: var(--text);
    font-size: 28px;
    font-weight: 800;
    line-height: 1.1;
}

.metric-card .inline-actions {
    margin-top: 18px;
}

/* SECTION HEADERS */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-header h1,
.section-header h2 {
    margin: 0;
    color: var(--purple-900);
}

.section-header h1 {
    font-size: 40px;
}

.section-header h2 {
    font-size: 24px;
}

/* TABLES */
.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    min-width: 980px;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.data-table thead th {
    background: linear-gradient(135deg, #f3ebff, #f9f4ff);
    color: var(--purple-900);
    font-size: 14px;
    letter-spacing: 0.25px;
    font-weight: 800;
    border-bottom: 1px solid var(--border);
}

.data-table th,
.data-table td {
    padding: 14px 12px;
    text-align: left;
    vertical-align: middle;
}

.data-table tbody td {
    border-bottom: 1px solid #ede2fb;
    color: var(--text);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(243, 235, 255, 0.45);
}

.data-table tbody tr:hover {
    background: rgba(237, 201, 104, 0.10);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* TABLE ACTIONS */
.data-table td .inline-actions {
    gap: 8px;
    align-items: center;
    justify-content: flex-start;
    row-gap: 8px;
}

.data-table td .inline-actions .button,
.data-table td .inline-actions button,
.data-table td form .button,
.data-table td form button,
.data-table td > .button,
.data-table td > button {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 13px;
}

.data-table td form {
    display: inline-flex;
    margin: 0;
}

.data-table td:last-child,
.data-table th:last-child {
    min-width: 190px;
}

.data-table td:last-child .inline-actions {
    flex-wrap: wrap;
}

.data-table td .button + .button,
.data-table td button + .button,
.data-table td .button + button,
.data-table td button + button {
    margin-left: 0;
}

/* PREVENT SMALL CARD TABLES FROM SQUEEZING ACTIONS */
.card .table-wrap {
    overflow-x: auto;
}

.card .data-table {
    min-width: 760px;
}

/* TAGS */
.tag {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.tag-green {
    background: rgba(34, 115, 67, 0.10);
    color: #1f7441;
    border: 1px solid rgba(34, 115, 67, 0.20);
}

.tag-red {
    background: rgba(160, 45, 45, 0.10);
    color: #a12b2b;
    border: 1px solid rgba(160, 45, 45, 0.20);
}

.tag-blue {
    background: rgba(79, 20, 138, 0.10);
    color: var(--purple-800);
    border: 1px solid rgba(79, 20, 138, 0.20);
}

.help-text {
    margin-top: 6px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.35;
}

/* CHECKBOXES */
.checkbox-row,
.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f7f1ff;
    border: 1px solid var(--border);
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--text);
}

.checkbox-item input {
    width: auto;
    margin: 0;
}

.recurrence-panel {
    margin-top: 16px;
    padding: 18px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #fdfaff 0%, #f5edff 100%);
}

.note-box {
    padding: 14px 16px;
    border-radius: 14px;
    background: linear-gradient(180deg, #fffaf0 0%, #fff4da 100%);
    border: 1px solid rgba(217, 173, 55, 0.30);
    color: #6a4b06;
}

/* FOOTER */
.site-footer {
    margin-top: 10px;
    background: linear-gradient(135deg, var(--purple-950), var(--purple-800));
    border-top: 2px solid rgba(237, 201, 104, 0.55);
    padding: 20px 0;
}

.footer-inner {
    width: min(1280px, calc(100% - 40px));
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.footer-inner img {
    height: 150px;
    width: auto;
    display: block;
}

.footer-inner p {
    margin: 0;
    color: rgba(255, 255, 255, 0.88);
    font-size: 14px;
    font-weight: 600;
}

ul {
    padding-left: 20px;
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* RESPONSIVE */
@media (max-width: 1180px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .header-inner,
    .page-shell,
    .footer-inner {
        width: min(1280px, calc(100% - 28px));
    }
}

@media (max-width: 900px) {
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .brand img {
        height: 66px;
    }

    .brand-title {
        font-size: 28px;
    }

    .site-nav {
        width: 100%;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .section-header h1 {
        font-size: 34px;
    }

    .dashboard-grid,
    .form-grid,
    .form-grid-3,
    .checkbox-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .page-shell,
    .header-inner,
    .footer-inner {
        width: min(1280px, calc(100% - 20px));
    }

    .page-shell {
        margin-top: 22px;
    }

    .card {
        padding: 18px;
    }

    .brand img {
        height: 60px;
    }

    .brand-title {
        font-size: 24px;
    }

    .site-nav a,
    .button,
    button {
        width: 100%;
    }

    .data-table {
        min-width: 760px;
    }

    .data-table td:last-child,
    .data-table th:last-child {
        min-width: 210px;
    }
}