:root {
    --rad-primary: #0d6efd;       /* Синій - основний */
    --rad-primary-hover: #0b5ed7;
    --rad-success: #198754;       /* Зелений */
    --rad-danger: #dc3545;        /* Червоний */
    --rad-bg: #f8f9fa;            /* Світлий фон */
    --rad-text: #212529;          /* Темний текст */
    --rad-border: #dee2e6;        /* Сірі рамки */
    --rad-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* === ВІДЖЕТ НА САЙТІ === */
.rad-widget-wrapper {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    justify-content: center; /* Центрування на сторінці */
    margin: 20px 0;
}

.rad-card {
    background: #fff;
    border: 1px solid var(--rad-border);
    border-radius: 8px;
    padding: 15px 25px;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
    min-width: 200px;
}

.rad-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--rad-shadow);
    border-color: var(--rad-primary);
}

.rad-card-header {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 5px;
    font-weight: 500;
}

.rad-card-body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rad-value-main {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--rad-text);
    line-height: 1.1;
}

.rad-unit {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 2px;
}

/* === МОДАЛЬНЕ ВІКНО === */
.rad-modal {
    position: fixed; 
    z-index: 10000; /* Поверх всього Joomla */
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); /* Затемнення фону */
    backdrop-filter: blur(3px); /* Ефект розмиття */
    display: flex;
    align-items: center;
    justify-content: center;
}

.rad-modal-content {
    background-color: #fff;
    margin: auto;
    padding: 25px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px; /* Не дуже широке */
    border-radius: 12px;
    box-shadow: 0 1rem 3rem rgba(0,0,0,0.2);
    position: relative;
    animation: radFadeIn 0.3s;
}

@keyframes radFadeIn {
    from {opacity: 0; transform: translateY(-20px);}
    to {opacity: 1; transform: translateY(0);}
}

.rad-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
    transition: color 0.2s;
}

.rad-close:hover {
    color: #000;
}

/* === КАЛЕНДАР === */
.rad-calendar-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 1.2rem;
    font-weight: bold;
}

.rad-calendar-controls button {
    background: none;
    border: 1px solid var(--rad-border);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-weight: bold;
    color: var(--rad-text);
}

.rad-calendar-controls button:hover {
    background-color: var(--rad-bg);
    border-color: #aaa;
}

.rad-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 0.9rem;
    color: #6c757d;
}

.rad-calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.rad-day {
    aspect-ratio: 1 / 1; /* Квадратні клітинки */
    border: 1px solid var(--rad-border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    cursor: default;
    background: #fff;
    position: relative;
    padding: 2px;
}

.rad-day.has-value {
    background-color: #e6f4ea; /* Світло-зелений для заповнених */
    border-color: #c3e6cb;
    cursor: pointer;
    font-weight: bold;
    color: var(--rad-success);
}

.rad-day.has-value:hover {
    background-color: #d4edda;
}

.rad-day.empty {
    background-color: #f8f9fa; /* Сірий для пустих */
    color: #ccc;
}

.rad-day-num {
    position: absolute;
    top: 2px;
    left: 4px;
    font-size: 0.7rem;
    color: #999;
}

/* Підсвітка сьогоднішньої дати */
.rad-day.today {
    border: 2px solid var(--rad-primary);
}

/* === ФОРМИ === */
.rad-view h3 {
    margin-top: 0;
    margin-bottom: 20px;
    text-align: center;
    color: var(--rad-text);
}

.rad-form-group {
    margin-bottom: 15px;
}

.rad-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.rad-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--rad-border);
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box; /* Важливо для відступів */
}

.rad-input:focus {
    outline: none;
    border-color: var(--rad-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.25);
}

.rad-input-large {
    font-size: 1.5rem;
    text-align: center;
    font-weight: bold;
}

.rad-form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 25px;
    gap: 10px;
}

.rad-btn-primary, .rad-btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    flex: 1;
}

.rad-btn-primary {
    background-color: var(--rad-primary);
    color: #fff;
}
.rad-btn-primary:hover { background-color: var(--rad-primary-hover); }

.rad-btn-secondary {
    background-color: #6c757d;
    color: #fff;
}
.rad-btn-secondary:hover { background-color: #5c636a; }

.rad-btn-link {
    background: none;
    border: none;
    color: var(--rad-primary);
    cursor: pointer;
    text-decoration: underline;
    padding: 5px;
}

.rad-text-danger { color: var(--rad-danger); }

.rad-footer-link {
    margin-top: 20px;
    text-align: center;
    font-size: 0.8rem;
}
.rad-footer-link a {
    color: #ccc;
    text-decoration: none;
}
.rad-footer-link a:hover { color: #888; }

/* === ТАБЛИЦЯ КОРИСТУВАЧІВ === */
.rad-users-table-wrapper {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 1px solid var(--rad-border);
    border-radius: 6px;
}

.rad-table {
    width: 100%;
    border-collapse: collapse;
}

.rad-table th, .rad-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--rad-border);
}

.rad-table th {
    background-color: #f1f1f1;
    position: sticky;
    top: 0;
}

.rad-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 5px;
}

.rad-admin-panel-footer {
    margin-top: 30px;
    text-align: center;
}