* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #121212;
    color: #e8e8e8;
    overflow: hidden;
}

body.light-theme {
    background: #f5f7fb;
    color: #1f2937;
}

body.light-theme .month-panel,
body.light-theme .compact-stats-panel,
body.light-theme .tile {
    background: #ffffff;
    border-color: #d4d9e2;
}

body.light-theme .bottom-panel {
    background: #ffffff;
    border-top-color: #d4d9e2;
}

body.light-theme .month-day {
    background: rgba(30, 41, 59, 0.1);
}

body.light-theme .month-day.filled,
body.light-theme .tile-bottom-progress,
body.light-theme .indicator-progress {
    background: #4f7cff;
}

body.light-theme .mic-button {
    color: #334155;
}

body.light-theme .mic-label {
    color: rgba(51, 65, 85, 0.85);
}

body.light-theme .mic-button.is-active .material-icons,
body.light-theme .mic-button.is-active .mic-label {
    color: #4f7cff;
}

body.light-theme .mic-button.is-active::before {
    background: rgba(79, 124, 255, 0.22);
}

body.light-theme .mic-label,
body.light-theme .indicator-label {
    color: rgba(51, 65, 85, 0.8);
}

body.light-theme .indicator-value,
body.light-theme .tile-name,
body.light-theme .tile-budget,
body.light-theme .tile-spent,
body.light-theme .tile-leftover,
body.light-theme .tile-fact-line,
body.light-theme .tile-plan-line {
    color: #1f2937;
}

body.light-theme .month-row-stars {
    color: #b45309;
}

body.light-theme .month-row-speed {
    color: #334155;
}


.budget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.budget-table th,
.budget-table td {
    padding: 6px 6px;
    text-align: left;
    border-bottom: 1px solid #2d2d2d;
}

.budget-table th {
    color: rgba(255, 255, 255, 0.65);
    font-weight: 600;
    font-size: 14px;
}

.budget-table th.budget-table-th-num,
.budget-table td.budget-table-td-num {
    text-align: right;
    white-space: nowrap;
    padding-left: 8px;
    padding-right: 6px;
}

.budget-table-td-cat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.budget-table-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.budget-table-name {
    color: #fff;
    font-weight: 500;
}

.budget-table-badge {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
    margin-left: 4px;
}

.budget-table-td-num {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

.budget-table-row {
    cursor: pointer;
}

.budget-table-row:hover {
    background: rgba(91, 141, 239, 0.08);
}

body.light-theme .budget-table th,
body.light-theme .budget-table td {
    border-bottom-color: #e2e8f0;
}

body.light-theme .budget-table th {
    color: #64748b;
}

body.light-theme .budget-table-name { color: #1f2937; }
body.light-theme .budget-table-td-num { color: #334155; font-size: 14px; }
body.light-theme .budget-table-badge { color: #94a3b8; }
body.light-theme .budget-table-row:hover { background: rgba(79, 124, 255, 0.06); }
.container {
    width: 100%;
    max-width: 480px;
    height: 100vh;
    height: 100dvh; /* mobile: visible viewport (address bar accounted) */
    margin: 0 auto;
    padding: 0 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.month-row {
    margin: 10px 0 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: center;
}

.month-row-left {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.month-row-left .indicator-label {
    margin: 0;
}

.month-row-stars {
    color: #ffd75e;
    font-size: 14px;
    letter-spacing: 2px;
    position: relative;
    top: -1px;
}

.month-row-speed {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
}

.month-row-divider {
    width: 1px;
    align-self: stretch;
    min-height: 18px;
    background: #2d2d2d;
}

body.light-theme .month-row-divider {
    background: #d4d9e2;
}

.month-row-discipline-wrap,
.month-row-speed-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

body.settings-hide-discipline .month-row-discipline-wrap {
    display: none;
}

body.settings-hide-speed .month-row-speed-wrap {
    display: none;
}

body.settings-hide-discipline .month-row-divider,
body.settings-hide-speed .month-row-divider {
    display: none;
}

body.settings-hide-group-filter #groupFilter {
    display: none;
}

body.settings-hide-voice #voiceInputBtn {
    display: none;
}

body.settings-hide-voice .bottom-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.demo-mini-btn,
.theme-mini-btn {
    width: 36px;
    height: 36px;
    min-height: 36px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.demo-mini-btn .material-icons,
.theme-mini-btn .material-icons {
    font-size: 14px;
    line-height: 1;
}

body.light-theme .demo-mini-btn,
body.light-theme .theme-mini-btn {
    background: transparent;
    color: #334155;
}

.month-days {
    display: grid;
    grid-template-columns: repeat(31, minmax(0, 1fr));
    gap: 2px;
}

.month-day {
    height: 6px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.09);
}

.month-day.filled {
    background: #5b8def;
}

.month-day.today {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.compact-stats-panel {
    height: 58px;
    margin: 4px 0 0;
    padding: 0 8px 0 10px;
    border: 1px solid #2d2d2d;
    border-radius: 14px;
    background: #171717;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    column-gap: 4px;
    align-items: center;
}

.compact-stats-panel .indicator {
    min-width: 0;
    border-right: none;
    padding: 7px 10px;
}

.compact-stats-panel .indicator-value {
    font-size: 12px;
}

.compact-stats-panel .metric {
    text-align: center;
}

.compact-stats-panel .metric.metric-over {
    display: none;
}

.compact-stats-panel .metric.metric-left {
    border-right: none;
    margin-right: 0;
}

.compact-stats-panel .indicator::after {
    content: '';
    position: absolute;
    right: 0;
    top: 10px;
    bottom: 10px;
    width: 1px;
    background: #2d2d2d;
}

.freeze-mini-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: #171717;
    color: rgba(255, 255, 255, 0.85);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.freeze-mini-btn .material-icons {
    font-size: 18px;
    line-height: 1;
}

.freeze-mini-btn.is-active {
    background: rgba(79, 124, 255, 0.2);
}

.freeze-mini-btn.active {
    background: rgba(91, 141, 239, 0.25);
    color: #fff;
}

body.light-theme .freeze-mini-btn {
    background: #ffffff;
    color: #334155;
}

body.light-theme .freeze-mini-btn.is-active {
    background: rgba(79, 124, 255, 0.12);
}

body.light-theme .freeze-mini-btn.active {
    background: rgba(79, 124, 255, 0.15);
    color: #1f2937;
}

.tiles-container {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-auto-rows: 110px;
    grid-auto-flow: row;
    width: calc(100% + 20px);
    margin-left: -10px;
    margin-right: -10px;
    padding: 8px 10px;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    justify-items: stretch;
    align-items: stretch;
    box-sizing: border-box;
}

.bottom-panel {
    height: 64px;
    min-height: calc(64px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    width: calc(100% + 20px);
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
    padding-top: 0;
    border-top: 1px solid #2d2d2d;
    background: #121212;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
    gap: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}

#mainScreen.hidden {
    display: none;
}


.indicator {
    flex: 1;
    position: relative;
    border: none;
    border-right: 1px solid #2d2d2d;
    border-radius: 0;
    background: transparent;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    justify-content: space-between;
    padding: 8px 12px;
    height: 100%;
    overflow: hidden;
}

.indicator-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0%;
    height: 3px;
    background: #5b8def;
    z-index: 0;
    transition: width 0.35s ease;
}

.metric {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
    padding-right: 10px;
}

.metric.metric-plan {
    border-right: 1px solid #2d2d2d;
    margin-right: 10px;
}

.metric.metric-fact {
    border-right: 1px solid #2d2d2d;
    margin-right: 10px;
}

.metric.metric-left {
    border-right: 1px solid #2d2d2d;
    margin-right: 10px;
}

.metric.metric-over {
    margin-right: 10px;
}

.metric.metric-over.is-over .indicator-value {
    color: #f87171;
}

body.light-theme .metric.metric-over.is-over .indicator-value {
    color: #dc2626;
}

body.light-theme .compact-stats-panel .indicator::after {
    background: #e2e8f0;
}

body.light-theme .metric.metric-plan,
body.light-theme .metric.metric-fact,
body.light-theme .metric.metric-left {
    border-right-color: #e2e8f0;
}

.indicator-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 2px;
}

.indicator-value {
    font-size: 14px;
    color: #ffffff;
    font-weight: 600;
}

.mic-button {
    position: relative;
    width: 100%;
    min-width: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #f2f2f2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.mic-button:hover {
    background: rgba(91, 141, 239, 0.12);
}

.mic-button-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.mic-button .material-icons {
    font-size: 20px;
}

.mic-button-badge {
    display: none;
    position: absolute;
    top: -2px;
    right: -4px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    pointer-events: none;
}

.mic-button.has-unsaved .mic-button-badge {
    display: block;
}

body.light-theme .mic-button-badge {
    background: #dc2626;
}

.mic-label {
    font-size: 10px;
    line-height: 1;
    color: rgba(255, 255, 255, 0.8);
}

.mic-button.is-active {
    background: transparent;
}

.mic-button.is-active::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 40px;
    border-radius: 12px;
    background: rgba(123, 163, 212, 0.28);
    pointer-events: none;
}

.mic-button.is-active .material-icons,
.mic-button.is-active .mic-label {
    color: #7ba3d4;
}
#voiceInputBtn.mic-on .material-icons,
#voiceInputBtn.mic-on .mic-label {
    color: #ef4444;
}
body.light-theme #voiceInputBtn.mic-on .material-icons,
body.light-theme #voiceInputBtn.mic-on .mic-label {
    color: #dc2626;
}

.group-filter {
    width: calc(100% + 20px);
    margin: 4px -10px 0;
    padding: 8px 10px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    border-bottom: 1px solid #2d2d2d;
    background: #171717;
}

.group-filter-groups {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.group-filter-search-wrap {
    display: none;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.group-filter-search-open .group-filter-groups,
.group-filter-search-open .group-filter-search-btn {
    display: none;
}

.group-filter-search-open .group-filter-search-wrap {
    display: flex;
}

.group-filter-search-input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid #2d2d2d;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    color: #f2f2f2;
    outline: none;
}

.group-filter-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.group-filter-search-input:focus {
    border-color: #5b8def;
}

body.light-theme .group-filter-search-input {
    background: #f1f5f9;
    border-color: #e2e8f0;
    color: #1e293b;
}

body.light-theme .group-filter-search-input::placeholder {
    color: #94a3b8;
}

body.light-theme .group-filter-search-input:focus {
    border-color: #5b8def;
}

.group-filter::-webkit-scrollbar {
    height: 0;
}

.group-filter-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 36px;
    min-height: 36px;
    padding: 8px;
    border: 1px solid #2d2d2d;
    border-radius: 50%;
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.group-filter-btn .material-icons {
    font-size: 20px;
    line-height: 1;
}

.group-filter-btn:hover {
    background: rgba(91, 141, 239, 0.12);
    border-color: rgba(91, 141, 239, 0.4);
}

.group-filter-btn.active {
    background: rgba(91, 141, 239, 0.25);
    border-color: #5b8def;
    color: #fff;
}

.group-filter-btn.active .material-icons {
    color: inherit;
}

body.light-theme .group-filter {
    border-bottom-color: #d4d9e2;
    background: #ffffff;
}

body.light-theme .group-filter-btn {
    border-color: #d4d9e2;
    color: #334155;
}

body.light-theme .group-filter-btn:hover {
    background: rgba(79, 124, 255, 0.08);
    border-color: #4f7cff;
}

body.light-theme .group-filter-btn.active {
    background: rgba(79, 124, 255, 0.15);
    border-color: #4f7cff;
    color: #1f2937;
}
